-->
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: @Entity(polymorphism=PolymorphismType.EXPLICIT)
PostPosted: Mon Mar 05, 2007 5:47 pm 
Beginner
Beginner

Joined: Thu Sep 16, 2004 8:14 pm
Posts: 27
I am trying to exclude a subclass from Hibernate's polymorphic queries. I have an abstract Content class mapped with
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

I have a File class which extends Content and a FileRevision class which extends File. FileRevision is a separate table that holds all revisions that have been made to a File. We also have the same setup for Text.

Content <- Text <- TextRevision

When we query against Content we would like to find all Files and Texts, but not FileRevision nor TextRevision. When I add @Entity(polymorphism=PolymorphismType.EXPLICIT) to FileRevision Hibernate continues to union queries from the file and filerevision tables. However, when I add the same annotation to File it will not query the file nor filerevision tables and does return Text.
Is there any way I can exclude FileRevision and TextRevision from Hibernate's polymorphic query?


Top
 Profile  
 
 Post subject: found a relevant Jira entry
PostPosted: Tue Mar 06, 2007 7:00 pm 
Beginner
Beginner

Joined: Thu Sep 16, 2004 8:14 pm
Posts: 27
http://opensource.atlassian.com/project ... se/ANN-314

However, I don't fully understand the response there:

"you misunderstood polymorphism.
polymorphism explicit only applies on root entities and prevent queries naming a (unmapped) superclass to return mapped sub entities

if your case if ObjectA were not mapped and ObjectB were having polymorphism explicit, then from ObjectA would not return ObjectB elements"

Why does this only apply to "root entities?" Is there a way to have both ObjectA and ObjectB mapped, but restrict Hibernate from looking for ObjectB's unless explicitly told to (in other words, not included as part of a polymorphic query)?

Thanks.


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.