-->
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.  [ 5 posts ] 
Author Message
 Post subject: Polymorphic queries
PostPosted: Tue Dec 07, 2004 11:50 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
I have class B which extends class A. Both have their own mappings, but there is no relationship mentioned between them in this mappings.

I'm executing query on class A and I also get instances of class B.

Ok, looking through source I see that QueryTranslator picks up (factory.getImplementors) all classes that are subclasses, so behaviour is normal.

What if I'm only querying on some properties which are only declared in mapping A and not in mapping B?

How could I only get just instances of A class?

Thanx, Ales


Hibernate version: 2.1.7


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 12:14 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
mapping A:

polymorphism="explicit"

:-)

But what about that only querying on properties of mapping A?
Who checks if those properties exist in other mappings?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 12:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
B is a subclass, A does not have properties that B does not have.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 1:45 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Ok, looking as subclass, B sure does have all properties A has.
But since mappings aren't connected in any way (no subclass, joined-class), only class B extends class A.

I have property 'foo' which is declared in mapping A, but it is not declared in mapping B. I do a query involving this property, who would know that this property doesn't exist in mapping B, so additional query for class B wouldn't be generated by QueryTranslator picks up (factory.getImplementors)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 1:47 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
'picks up' is obsolete.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.