-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: 'Abstract Entity' annotation ?? MappedSuperClass unusable
PostPosted: Fri Dec 01, 2006 3:18 pm 
Newbie

Joined: Fri Dec 01, 2006 10:01 am
Posts: 6
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 ?

Thanks,

Jeroen


Quote:
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 11:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Inheritance TABLE_PER_CLASS is the equivalent to union-subclass

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.