I have a general question and a specific one:
The general question is: I'm working with a class hierarchy: ClassA<--ClassB<--ClassC, for example, it can be a Person<--Employee<--Manager hierarchy. I wonder what is the best practice for mapping such a class hierarchy using Hibernate.
The specific question is: I've tried to map the class hierarchy using the table-per-class-hierarchy strategy, but I'd want to use a different discriminator for the ClassA<--ClassB branch than that for the ClassB<--ClassC branch. For Hibernate-2.1, it does not allow to specify a discriminator in the mapping of ClassB (such that the mapping of ClassC and its sibling classes can have a discriminator-value attribute): I got exception for doing this with the complain that the discriminator element need to be defined for the subclass element. I understand that Hibernate-3 offers more in o-r mapping options, so I downlowed Hibernate-3 from cvs and built it, then I removed the hibernate2.jar, replacing it with hibernate3.jar. Generating Java code and compile them were fine. But when I tried to generate the database schema, I got:
java.lang.NoClassDefFoundError: net/sf/hibernate/MappingException
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
Can someones shine some lights on the subject? Thanks in advance.
|