Hi,
I am using Hibernate version 3.
I am trying to map a single class "Animal" into 2 tables "ExtinctAnimals" and "NonExtinctAnimals" depending on the value of the "extinct" property. If the object has a value of "true" for the extinct property, then it should be stored into the "ExtinctAnimals" table. If it has a value of "false", then it should be stored in the "NonExtinctAnimals" table.
The same should also occur while loading the object. So, it the object is loaded from the "ExtinctAnimals" table, it should automatically set the value of the "extinct" property to true.
I would like to know what kind of mappings to use for the same. I tried the following :
Code:
<class name="Animal" entity-name="ExtinctAnimals" discriminator-value="true">
<discriminator column="extinct" />
...
</class>
<class name="Animal" entity-name="NonExtinctAnimals" discriminator-value="false">
<discriminator column="extinct" />
...
</class>
But, Hibernate complains that the classes "ExtinctAnimals" and "NonExtinctAnimals" do not exist. Attached at the bottom is the stack trace.
What would be a good mapping for my problem?
Or are there better recommended ways of doing things?
Thanks in advance.
Java Exception :
Caused by: java.lang.ClassNotFoundException: ExtinctAnimals
at java.net.URLClassLoader.findClass(URLClassLoader.java:376)
at java.lang.ClassLoader.loadClass(ClassLoader.java:570)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:442)
at java.lang.ClassLoader.loadClass(ClassLoader.java:502)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:180)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:76)
Code: