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: Polymorphism="explicit" query yields subclasses
PostPosted: Wed Aug 09, 2006 7:47 pm 
Newbie

Joined: Tue Aug 01, 2006 9:42 pm
Posts: 6
My understanding of how Polymorphism="explicit" works might be flawed so someone bring me back to reality here:

In a situation as shown below in:

ClassA <-- ClassB

where ClassB derives from ClassA and ClassA is mapped with the attribute Polymorphism="explicit"; When I formulate a query with the predicate "FROM ClassA as A WHERE A.SomeProperty > 4" I should get in my resultset only instances which are explicitly of type ClassA right? I shouldn't get any ClassB instances.

If this is not true, or if I have missed some crucial point, someone please set me straight. If this is true and I haven't missed anything I have an example which perplexes me that I will post as a response.


Hibernate version: NHibernate-1.2.0.Alpha1-debug


Top
 Profile  
 
 Post subject: RE: Polymorphism="explicit" query yields subclasse
PostPosted: Thu Aug 10, 2006 5:33 pm 
Newbie

Joined: Tue Aug 01, 2006 9:42 pm
Posts: 6
So, I found my answer in the following thread in the Hibernate forum:

http://forum.hibernate.org/viewtopic.php?t=399&highlight=explicit+polymorphism

It looks like the class attribute polymorphism='explicit' has absolutely no effect on class hierarchies with subclasses mapped with <joined-subclass> but rather only on class hierarchies with classes mapped as <subclass> using the table per class hierarchy approach. To get the behavior I described in my first post it looks like you would formulate an HQL query as follows:

FROM ClassA as c WHERE c.class = MyNamespace.ClassA

this filters the list of returned object instances to be only those which are explicitly ClassA instances and not also ClassB instances etc.

Hope this helps someone.[/url]


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.