Hi,
Since i didn't get any info, i'm trying to rephrase my question (previous question below in quote) :
It turns out one cannot use a @MappedSuperClass in a hibernate query with Criteria.
In the hbm-file approach, this was possible by specifying an entity as 'abstract' like this :
<class name="Module" abstract="true">...
That way, hibernate constructed a union-query going through the tables of subclasses, since my Module-class has no table equivalent.
Now it seems i need to find the annotations-way to get the same thing:
Use a Module-object to query through subclasses of Module.
Anyone have a clue about what annotation to use ? Or a different approach ? The fact is that it works with the old *.hbm.xml file approach, but i don't find an annotation equivalent ...
Thanks,
Jeroen
I've got the following problem :
I'm stuck with an existing DB-system that wasn't too well designed.
Now i'm trying to build a web-application to access it.
What i'm trying to do now is build a search-page.
I have two tables called Applmod & Communicator
Both contain entities called 'Modules' to the system, but the Communicator ones have more specific members.
With regular hibernate mapping files, i was able to do the following :
- create an abstract entitity called Module that contains the common members of both Applmod & Communicator (like applmodid, etc.)
The configuration Module.hbm.xml is something like :
<class name="Module" abstract="true">
<property name="applmodid"></property>
...
<union-subclass name="Applmod" table="APPLMOD">
...
</union-subclass>
<union-subclass name="Communicator" table="COMMUNICATOR">
...
</union-subclass>
</class>
Now what i was able to do is to do a hibernate query on Module, where the respons that i got was a list containing both Applmod & Communicator objects mixed together.
Now with the new annotations i don't succeed in querying the Module class anymore, since, as it turns out, if a class is not annotated as Entity , it's not loaded by an AnnotatedSessionFactory.
In the documentation they talk about MappedSuperClasses and the likes , but they have the same problem. Mapping Module as @Entity doesn't work, since it doesn't exist as a physical table.
Does anyone have experience/ideas about how i can get it to work with Annotations ?
Thanks !
Jeroen
|