FAQ
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();

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 6 | next ›
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