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.
This archive was generated by hypermail 2.0.0 : Tue Nov 02 2010 - 13:59:44 UTC