Re: nodes for standalone application

From: Andrus (andru..bjectstyle.org)
Date: Fri May 03 2002 - 09:44:22 EDT

  • Next message: Andrus: "Re: nodes for standalone application"

    Hi Robert,

    You may find some information on files format in User Guide at
    http://objectstyle.org/cayenne/userguide/appguide/project.html , though I
    think it needs to be extended with more examples. Also try using
    CayenneModeler tool, select data node (green DB icon), it will have choices
    in drop down lists. Most of them are self-explanatory.

    Answering your question for standalone app (if DataSource from container is
    used, different approach should be taken):

    1. Factory. Use "org.objectstyle.cayenne.conf.DriverDataSourceFactory" that
    will wrap your JDBC driver.

    2. Adapter. Depends on database. For Oracle use
    "org.objectstyle.cayenne.dba.oracle.OracleAdapter"

    3. Datasource. In this case "datasource" attribute means a location of
    another config file that contains your driver information. Location is
    resolved relative to the directory (real or in Jar) of "cayenne.xml" file.
    For instance if you have C:\Temp\cayenne.xml and C:\Temp\driverinfo.xml,
    then datasource entry will be datasource="driverinfo.xml"

    4. map-ref. This element is used to link a DataMap that belongs to domain
    with a particular node. In a simple case this looks redundant, but Cayenne
    supports multiple maps and nodes (datasources) and allows to make complex
    associations between them.

    Example of cayenne.xml:
    ===================================
    <?xml version="1.0" encoding="utf-8"?>
    <domains>
    <domain name="main">
             <map name="map" location="datamap.xml"/>
             <node name="db1"
                  adapter="org.objectstyle.cayenne.dba.mysql.MySQLAdapter"
                     datasource="driverinfo.xml"
                     factory="org.objectstyle.cayenne.conf.DriverDataSourceFactory">
                             <map-ref name="entmap"/>
             </node>
    </domain>
    </domains>
    ==================================

    Example of driverinfo.xml:
    ===================================
    <?xml version="1.0" encoding="utf-8"?>
    <driver class="oracle.jdbc.driver.OracleDriver">
         <connectionPool min="1" max="1"/>
         <url value="jdbc:oracle:thin..racleserver:1521:db"/>
         <login userName="test" password="test"/>
    </driver>
    ==================================

    Hope this helps. We will continue working on docs :-) (any contributions
    are welcomed). Also later today I will be checking a fix of a problem with
    cayenne.jar in ..../lib/ext. It should be included in the next automated
    nightly build.

    At 08:35 PM 5/2/2002 -0400, Robert John Andersen wrote:
    >What goes into the values for factory, datasource, and adapter in the node
    >element? Also what is the map-ref element used for?
    >
    >RJA



    This archive was generated by hypermail 2.0.0 : Fri May 03 2002 - 09:44:09 EDT