FAQ
Hey all,

I'm still on my quest to get this stuff loaded dynamically. Here's what I'm
doing now, first I gutted the map xml file so that it looks like this:

TestProjectSourceMap.map.xml
<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
http://cayenne.apache.org/schema/3.0/modelMap.xsd"
project-version="3.0.0.1">
<property name="defaultPackage" value="org.example.cayenne.persistent"/>

</data-map>


Built a new Map xml file that had all of the real class associations and put
it someplace else, that file looks like this

TestProjectNewMap.map.xml
<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
http://cayenne.apache.org/schema/3.0/modelMap.xsd"
project-version="3.0.0.1">
<property name="defaultPackage" value="org.example.cayenne.persistent"/>
<db-entity name="ARTIST">
<db-attribute name="ArtistID" type="BIGINT" isPrimaryKey="true"
isMandatory="true"/>
<db-attribute name="Name" type="VARCHAR" length="255"/>
</db-entity>
....
<obj-relationship name="artist" source="Painting" target="Artist"
deleteRule="Nullify" db-relationship-path="artist"/>
</data-map>


All I want to do is load in this OTHER xml file, right now I'm getting
"Class is not mapped with Cayenne:
main.java.org.example.cayenne.persistent.Artist" which is because it has not
loaded my other xml file. Here is what I'm doing:


ObjectContext context = DataContext.createDataContext();

MapLoader ml = new MapLoader();

DataMap dataMap = ml.loadDataMap(new InputSource(new
FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\Map.map.xml")));

//This will bomb because I havent DONE anything with the datamap

Artist picasso = context.newObject(Artist.class);

So what do I do with that DataMap to get it loaded into the context? I've
been looking but I Don't see the method call I need to make to push that
DataMap anywhere. Note the other files (cayenne.xml,
TestProjectNode.driver.xml) remain unchanged.

Any help would be greatly appreciated.

Search Discussions

  • Mike Kienenberger at Nov 2, 2010 at 5:55 pm
    yourDataDomain.addMap(DataMap map)

    I'd also suggest creating the DataMap programmically unless you have
    some reason to want to do it from a static xml file.

    You used to be able to use the following code to fetch the data domain.

    DataDomain yourDataDomain = Configuration.getSharedConfiguration().getDomain();


    On Tue, Nov 2, 2010 at 9:59 AM, caden whitaker wrote:
    Hey all,

    I'm still on my quest to get this stuff loaded dynamically. Here's what I'm
    doing now, first I gutted the map xml file so that it looks like this:

    TestProjectSourceMap.map.xml
    <?xml version="1.0" encoding="utf-8"?>
    <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
    http://cayenne.apache.org/schema/3.0/modelMap.xsd"
    project-version="3.0.0.1">
    <property name="defaultPackage" value="org.example.cayenne.persistent"/>

    </data-map>


    Built a new Map xml file that had all of the real class associations and put
    it someplace else, that file looks like this

    TestProjectNewMap.map.xml
    <?xml version="1.0" encoding="utf-8"?>
    <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
    http://cayenne.apache.org/schema/3.0/modelMap.xsd"
    project-version="3.0.0.1">
    <property name="defaultPackage" value="org.example.cayenne.persistent"/>
    <db-entity name="ARTIST">
    <db-attribute name="ArtistID" type="BIGINT" isPrimaryKey="true"
    isMandatory="true"/>
    <db-attribute name="Name" type="VARCHAR" length="255"/>
    </db-entity>
    ....
    <obj-relationship name="artist" source="Painting" target="Artist"
    deleteRule="Nullify" db-relationship-path="artist"/>
    </data-map>


    All I want to do is load in this OTHER xml file, right now I'm getting
    "Class is not mapped with Cayenne:
    main.java.org.example.cayenne.persistent.Artist" which is because it has not
    loaded my other xml file. Here is what I'm doing:


    ObjectContext context = DataContext.createDataContext();

    MapLoader ml = new MapLoader();

    DataMap dataMap = ml.loadDataMap(new InputSource(new
    FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\Map.map.xml")));

    //This will bomb because I havent DONE anything with the datamap

    Artist picasso = context.newObject(Artist.class);

    So what do I do with that DataMap to get it loaded into the context? I've
    been looking but I Don't see the method call I need to make to push that
    DataMap anywhere. Note the other files (cayenne.xml,
    TestProjectNode.driver.xml) remain unchanged.

    Any help would be greatly appreciated.
  • Caden whitaker at Nov 2, 2010 at 6:03 pm
    Gotcha, right now the static xml is just for testing purposes, so I tossed
    that in there but I'm getting an error, is this the correct way to use the
    DataDomain:

    MapLoader ml = new MapLoader();
    DataMap dataMap = ml.loadDataMap(new InputSource(new
    FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\HelloWorld2Map.map.xml")));
    DataDomain dd =
    Configuration.getSharedConfiguration().getDomain();
    dd.addMap(dataMap);
    ObjectContext context = dd.createDataContext(false);


    System.out.println("START CREATE");
    Artist picasso = context.newObject(Artist.class);
    picasso.setName("Pablo Picasso");


    Painting girl = context.newObject(Painting.class);
    girl.setName("Girl Reading at a Table");
    girl.setArtist(picasso);

    Painting stein = context.newObject(Painting.class);
    stein.setName("Gertrude Stein");
    stein.setArtist(picasso);

    context.commitChanges();

    This throws an error, here is the stack:


    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    startedLoading
    INFO: started configuration loading.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataDomain
    INFO: loaded domain: HelloWorld1
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    loadDataMap
    INFO: loaded <map name='HelloWorld1Map' location='HelloWorld1Map.map.xml'>.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: loading <node name='HelloWorld1Node'
    datasource='HelloWorld1Node.driver.xml'
    factory='org.apache.cayenne.conf.DriverDataSourceFactory'
    schema-update-strategy='org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy'>.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: using factory: org.apache.cayenne.conf.DriverDataSourceFactory
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.DriverDataSourceFactory load
    INFO: loading driver information from 'HelloWorld1Node.driver.xml'.
    Nov 2, 2010 1:00:57 PM
    org.apache.cayenne.conf.DriverDataSourceFactory$DriverHandler init
    INFO: loading driver org.apache.derby.jdbc.EmbeddedDriver
    Nov 2, 2010 1:00:57 PM
    org.apache.cayenne.conf.DriverDataSourceFactory$LoginHandler init
    INFO: loading user name and password.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.access.QueryLogger logPoolCreated
    INFO: Created connection pool: jdbc:derby:memory:testdb;create=true
    Driver class: org.apache.derby.jdbc.EmbeddedDriver
    Min. connections in the pool: 1
    Max. connections in the pool: 1
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: loaded datasource.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    initAdapter
    INFO: no adapter set, using automatic adapter.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLinkDataMap
    INFO: loaded map-ref: HelloWorld1Map.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    finishedLoading
    INFO: finished configuration loading in 234 ms.
    START CREATE
    org.apache.cayenne.CayenneRuntimeException: [v.3.0RC2 Feb 03 2010 13:38:54]
    Commit Exception
    at
    org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1134)
    at
    org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)
    at
    main.java.org.example.cayenne.ut.CayenneUnitTest.testBuild(CayenneUnitTest.java:71)
    On Tue, Nov 2, 2010 at 12:55 PM, Mike Kienenberger wrote:

    yourDataDomain.addMap(DataMap map)

    I'd also suggest creating the DataMap programmically unless you have
    some reason to want to do it from a static xml file.

    You used to be able to use the following code to fetch the data domain.

    DataDomain yourDataDomain =
    Configuration.getSharedConfiguration().getDomain();


    On Tue, Nov 2, 2010 at 9:59 AM, caden whitaker wrote:
    Hey all,

    I'm still on my quest to get this stuff loaded dynamically. Here's what I'm
    doing now, first I gutted the map xml file so that it looks like this:

    TestProjectSourceMap.map.xml
    <?xml version="1.0" encoding="utf-8"?>
    <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
    http://cayenne.apache.org/schema/3.0/modelMap.xsd"
    project-version="3.0.0.1">
    <property name="defaultPackage"
    value="org.example.cayenne.persistent"/>
    </data-map>


    Built a new Map xml file that had all of the real class associations and put
    it someplace else, that file looks like this

    TestProjectNewMap.map.xml
    <?xml version="1.0" encoding="utf-8"?>
    <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
    http://cayenne.apache.org/schema/3.0/modelMap.xsd"
    project-version="3.0.0.1">
    <property name="defaultPackage"
    value="org.example.cayenne.persistent"/>
    <db-entity name="ARTIST">
    <db-attribute name="ArtistID" type="BIGINT" isPrimaryKey="true"
    isMandatory="true"/>
    <db-attribute name="Name" type="VARCHAR" length="255"/>
    </db-entity>
    ....
    <obj-relationship name="artist" source="Painting" target="Artist"
    deleteRule="Nullify" db-relationship-path="artist"/>
    </data-map>


    All I want to do is load in this OTHER xml file, right now I'm getting
    "Class is not mapped with Cayenne:
    main.java.org.example.cayenne.persistent.Artist" which is because it has not
    loaded my other xml file. Here is what I'm doing:


    ObjectContext context = DataContext.createDataContext();

    MapLoader ml = new MapLoader();

    DataMap dataMap = ml.loadDataMap(new InputSource(new
    FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\Map.map.xml")));
    //This will bomb because I havent DONE anything with the datamap
    Artist picasso = context.newObject(Artist.class);

    So what do I do with that DataMap to get it loaded into the context? I've
    been looking but I Don't see the method call I need to make to push that
    DataMap anywhere. Note the other files (cayenne.xml,
    TestProjectNode.driver.xml) remain unchanged.

    Any help would be greatly appreciated.
  • Mike Kienenberger at Nov 2, 2010 at 6:15 pm
    That looks reasonable to me. I don't actually have any Cayenne 3.x
    projects, though. My last one was Cayenne 2.0, so I'm not familiar
    with the new ObjectContext syntax off the top of my head.

    Do you get more error messages than that? Perhaps a bottom-most stack
    trace that gives more information why the commit failed?

    A shot in the dark would be that you're not specifying a primary key
    generator in your truncated DataMap for the Artist class.
    On Tue, Nov 2, 2010 at 2:03 PM, caden whitaker wrote:
    Gotcha, right now the static xml is just for testing purposes, so I tossed
    that in there but I'm getting an error, is this the correct way to use the
    DataDomain:

    MapLoader ml = new MapLoader();
    DataMap dataMap = ml.loadDataMap(new InputSource(new
    FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\HelloWorld2Map.map.xml")));
    DataDomain dd =
    Configuration.getSharedConfiguration().getDomain();
    dd.addMap(dataMap);
    ObjectContext context = dd.createDataContext(false);


    System.out.println("START CREATE");
    Artist picasso = context.newObject(Artist.class);
    picasso.setName("Pablo Picasso");


    Painting girl = context.newObject(Painting.class);
    girl.setName("Girl Reading at a Table");
    girl.setArtist(picasso);

    Painting stein = context.newObject(Painting.class);
    stein.setName("Gertrude Stein");
    stein.setArtist(picasso);

    context.commitChanges();

    This throws an error, here is the stack:


    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    startedLoading
    INFO: started configuration loading.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataDomain
    INFO: loaded domain: HelloWorld1
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    loadDataMap
    INFO: loaded <map name='HelloWorld1Map' location='HelloWorld1Map.map.xml'>.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: loading <node name='HelloWorld1Node'
    datasource='HelloWorld1Node.driver.xml'
    factory='org.apache.cayenne.conf.DriverDataSourceFactory'
    schema-update-strategy='org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy'>.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: using factory: org.apache.cayenne.conf.DriverDataSourceFactory
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.DriverDataSourceFactory load
    INFO: loading driver information from 'HelloWorld1Node.driver.xml'.
    Nov 2, 2010 1:00:57 PM
    org.apache.cayenne.conf.DriverDataSourceFactory$DriverHandler init
    INFO: loading driver org.apache.derby.jdbc.EmbeddedDriver
    Nov 2, 2010 1:00:57 PM
    org.apache.cayenne.conf.DriverDataSourceFactory$LoginHandler init
    INFO: loading user name and password.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.access.QueryLogger logPoolCreated
    INFO: Created connection pool: jdbc:derby:memory:testdb;create=true
    Driver class: org.apache.derby.jdbc.EmbeddedDriver
    Min. connections in the pool: 1
    Max. connections in the pool: 1
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: loaded datasource.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    initAdapter
    INFO: no adapter set, using automatic adapter.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLinkDataMap
    INFO: loaded map-ref: HelloWorld1Map.
    Nov 2, 2010 1:00:57 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    finishedLoading
    INFO: finished configuration loading in 234 ms.
    START CREATE
    org.apache.cayenne.CayenneRuntimeException: [v.3.0RC2 Feb 03 2010 13:38:54]
    Commit Exception
    at
    org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1134)
    at
    org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)
    at
    main.java.org.example.cayenne.ut.CayenneUnitTest.testBuild(CayenneUnitTest.java:71)
    On Tue, Nov 2, 2010 at 12:55 PM, Mike Kienenberger wrote:

    yourDataDomain.addMap(DataMap map)

    I'd also suggest creating the DataMap programmically unless you have
    some reason to want to do it from a static xml file.

    You used to be able to use the following code to fetch the data domain.

    DataDomain yourDataDomain =
    Configuration.getSharedConfiguration().getDomain();



    On Tue, Nov 2, 2010 at 9:59 AM, caden whitaker <caden.whitaker@gmail.com>
    wrote:
    Hey all,

    I'm still on my quest to get this stuff loaded dynamically. Here's what I'm
    doing now, first I gutted the map xml file so that it looks like this:

    TestProjectSourceMap.map.xml
    <?xml version="1.0" encoding="utf-8"?>
    <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
    http://cayenne.apache.org/schema/3.0/modelMap.xsd"
    project-version="3.0.0.1">
    <property name="defaultPackage"
    value="org.example.cayenne.persistent"/>
    </data-map>


    Built a new Map xml file that had all of the real class associations and put
    it someplace else, that file looks like this

    TestProjectNewMap.map.xml
    <?xml version="1.0" encoding="utf-8"?>
    <data-map xmlns="http://cayenne.apache.org/schema/3.0/modelMap"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap
    http://cayenne.apache.org/schema/3.0/modelMap.xsd"
    project-version="3.0.0.1">
    <property name="defaultPackage"
    value="org.example.cayenne.persistent"/>
    <db-entity name="ARTIST">
    <db-attribute name="ArtistID" type="BIGINT" isPrimaryKey="true"
    isMandatory="true"/>
    <db-attribute name="Name" type="VARCHAR" length="255"/>
    </db-entity>
    ....
    <obj-relationship name="artist" source="Painting" target="Artist"
    deleteRule="Nullify" db-relationship-path="artist"/>
    </data-map>


    All I want to do is load in this OTHER xml file, right now I'm getting
    "Class is not mapped with Cayenne:
    main.java.org.example.cayenne.persistent.Artist" which is because it has not
    loaded my other xml file. Here is what I'm doing:


    ObjectContext context = DataContext.createDataContext();

    MapLoader ml = new MapLoader();

    DataMap dataMap = ml.loadDataMap(new InputSource(new
    FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\Map.map.xml")));
    //This will bomb because I havent DONE anything with the datamap
    Artist picasso = context.newObject(Artist.class);

    So what do I do with that DataMap to get it loaded into the context? I've
    been looking but I Don't see the method call I need to make to push that
    DataMap anywhere. Note the other files (cayenne.xml,
    TestProjectNode.driver.xml) remain unchanged.

    Any help would be greatly appreciated.
  • Caden whitaker at Nov 2, 2010 at 6:23 pm
    Hrm.. here's the full stacktrace - if I take the XML and load it through
    normal cayenne processes the unit test passes, so the xml is valid, it must
    not be fully qualifying the DataMap for some reason.

    org.apache.cayenne.CayenneRuntimeException: [v.3.0RC2 Feb 03 2010 13:38:54]
    Commit Exception
    at
    org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1134)
    at
    org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)
    at
    main.java.org.example.cayenne.ut.CayenneUnitTest.testBuild(CayenneUnitTest.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at
    org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at
    org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at
    org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: java.lang.NullPointerException
    at
    org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(DataDomainInsertBucket.java:101)
    at
    org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(DataDomainInsertBucket.java:76)
    at
    org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(DataDomainSyncBucket.java:79)
    at
    org.apache.cayenne.access.DataDomainFlushAction.preprocess(DataDomainFlushAction.java:182)
    at
    org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:134)
    at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:824)
    at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:791)
    at
    org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:850)
    at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:788)
    at
    org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1106)
    ... 21 more
  • Caden whitaker at Nov 2, 2010 at 6:33 pm
    Got it working, here is the code, note this code can probably be reduced,
    but it at least did the job




    DataDomain dd =
    Configuration.getSharedConfiguration().getDomain();

    MapLoader ml = new MapLoader();
    DataMap dataMap = ml.loadDataMap(new InputSource(new
    FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\HelloWorld2Map.map.xml")));

    // Add the shared map to the target data domain
    dd.addMap(dataMap);

    // Add the shared map to the data node
    Collection nodes = dd.getDataNodes();

    if (nodes.size() != 1)
    {
    System.out.println("Expected only one DataNode for DataDomain
    '" +
    "" +
    "' -- this DataDomain is not usable.");
    return;
    }

    Iterator dataNodeIterator = nodes.iterator();

    // We are only getting one, though ...
    while (dataNodeIterator.hasNext())
    {
    DataNode node = (DataNode) dataNodeIterator.next();

    node.addDataMap(dataMap);
    }


    ObjectContext context = dd.createDataContext();


    Artist picasso = context.newObject(Artist.class);
    picasso.setName("Pablo Picasso");


    Painting girl = context.newObject(Painting.class);
    girl.setName("Girl Reading at a Table");
    girl.setArtist(picasso);

    Painting stein = context.newObject(Painting.class);
    stein.setName("Gertrude Stein");
    stein.setArtist(picasso);


    context.commitChanges();

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedNov 2, '10 at 1:59p
activeNov 2, '10 at 6:33p
posts6
users2
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase