Beginner |
|
Joined: Wed Jul 06, 2005 4:51 pm Posts: 27
|
one-to-many relation with not-null attribute on key element is throwing below error when I run the hbm2java tool. I have a base class with a joined-subclass and the joined subclass has one-to-many relationship with another class. The one-to-many uses a list. When I specify not-null attribute on the key element in the relationship I get the below error. If I remove it I don't get this error. If I let the key stay not-null, during run time persistence fails. So I had to revert the mapping file at runtime for the persistence to go fine. It is only the tool that is misbehaving.
---------> Mapping
Base class mapping:
<hibernate-mapping package="***.core">
<class name="Resource" table="Resource" polymorphism="explicit">
..............
</class>
Derived Class with one-to-many:
<hibernate-mapping package="***.chartbook">
<joined-subclass name="ChartDefinition" table="ChartDefinition"
extends="***.core.Resource">
<key column="chartDefinitionId"/>
.....
<list name="ChartSeries" cascade="all-delete-orphan" inverse="false">
<key column="chartDefinitionId" not-null="true"/>
<list-index column="position" />
<one-to-many class="ChartSeries"/>
</list>
</joined-subclass>
</hibernate-mapping>
--- target of one-to-many
<hibernate-mapping package="**.chartbook">
<class name="ChartSeries" table="ChartSeries">
<id name="Id" type="integer" column="chartSeriesId">
<generator class="identity"/>
</id>
</class>
</hibernate-mapping>
----------------> Error
org.hibernate.tool.hbm2x.ExporterException: Error while processing t
emplate pojo/javaclass.vm
at org.apache.tools.ant.Task.perform(Task.java:373)
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.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: org.hibernate.tool.hbm2x.ExporterException: Error while processing template pojo/javaclass.vm
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:89)
at org.hibernate.tool.hbm2x.POJOExporter.runVelocity(POJOExporter.java:78)
at org.hibernate.tool.hbm2x.POJOExporter.exportPersistentClass(POJOExporter.java:61)
at org.hibernate.tool.hbm2x.POJOExporter.start(POJOExporter.java:111)
at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:33)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
|
|