I've tried mapping using the H3 mappings in middlegen. It works fine except I'm unable to get my many-to-many mappings to work. When I try to run middlegen with references to many2many tables I get the following exception:
Code:
java.lang.NullPointerException
at middlegen.plugins.hibernate.HibernateRelationshipRole.init(HibernateRelationshipRole.java:259)
at middlegen.Plugin.decorateAll(Plugin.java:387)
at middlegen.Middlegen.decorateAll(Middlegen.java:312)
at middlegen.MiddlegenTask.execute(MiddlegenTask.java:406)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
My ant task looks like:
Code:
<target name="classgen" description="Generate Java classes from database schema">
<middlegen
appname="somedatabase"
prefsdir="doc/middlegen"
gui="true"
databaseurl="jdbc:jtds:sqlserver://someserver:1433/SOMEDB"
driver="net.sourceforge.jtds.jdbcx.JtdsDataSource"
username="A_USER"
password="secretpassword"
schema="dbo"
catalog="SOMEDB">
<!-- Optionally declare table elements -->
<table name="EventDataStream" />
<table name="EventDetectionParams" />
<table name="FrameEventSet" />
<table name="EventObject" />
<table name="BoundingBox" />
<table name="SourceMetadata" />
<table name="Classifier" />
<table name="TrainingSet" />
<table name="ClassImageSet" />
<table name="ValidationResults" />
<table name="Image" />
<table name="EventDataStream_Classifier" generate="false" />
<table name="TrainingSet_ClassImageSet" generate="false" />
<table name="ValidationResults_ClassImageSet" generate="false" />
<table name="ClassImageSet_Image" generate="false" />
<!-- Optionally declare many2many elements -->
<many2many>
<tablea name="EventDataStream"/>
<jointable name="EventDataStream_Classifier" generate="false"/>
<tableb name="Classifier"/>
</many2many>
<many2many>
<tablea name="TrainingSet"/>
<jointable name="TrainingSet_ClassImageSet" generate="false"/>
<tableb name="ClassImageSet"/>
</many2many>
<many2many>
<tablea name="ValidationResults"/>
<jointable name="ValidationResults_ClassImageSet" generate="false"/>
<tableb name="ClassImageSet"/>
</many2many>
<many2many>
<tablea name="ClassImageSet"/>
<jointable name="ClassImageSet_Image" generate="false"/>
<tableb name="Image"/>
</many2many>
<!-- One or more plugins -->
<hibernate
version="3.0"
destination="${src.java}"
package="${project}.hibernate"
javaTypeMapper="middlegen.plugins.hibernate.HibernateJavaTypeMapper" />
</middlegen>
</target>
If I remove the lines:
Code:
<table name="EventDataStream_Classifier" generate="false" />
<table name="TrainingSet_ClassImageSet" generate="false" />
<table name="ValidationResults_ClassImageSet" generate="false" />
<table name="ClassImageSet_Image" generate="false" />
Then it runs fine, except of course, I don't get my many-to-many mappings.
Any suggestions?
Thanks
Brian