-->
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.  [ 3 posts ] 
Author Message
 Post subject: getAll and Query give extra results for inherited classes
PostPosted: Thu Dec 01, 2005 3:23 am 
Newbie

Joined: Wed Nov 30, 2005 1:59 pm
Posts: 2
Hibernate version: 3.0

Suppose we have three inherited classes:

class A {...};
class B extends A {...};
class C extends B {...};

Classes B and C add few fileds to their parents. They have almost the same hibernate mappings. The difference is that A is mapped only to the fields of a single table T1, class B - adds one-to-one mapping to a T2 table and class C has a list mapped to T1 table through instance of A class.

For example consider that S[i] is an instance of S class innitialized with the i row of T1 table and T1 has two rows 1 and 2

The problem is:
When a call a getAll( Class class ) function or execute query for class A
i.e. getAll( A.getClass() )
the response I get is { A[1], A[2], B[1], B[2], C[1], C[2] },
for the getAll( B.getClass() )
the response is { B[1], B[2], C[1], C[2] }.

But I'd like to get { A[1], A[2] } and { B[1], B[2] } correspondingly. What should I do?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 5:56 am 
Regular
Regular

Joined: Tue Oct 28, 2003 8:25 am
Posts: 72
Location: Belgium
Aren't you looking for explicit polymorphism ?

Code:
<class name="SomeClass" polymorphism="explicit">
...
</class>

See http://www.hibernate.org/hib_docs/v3/re ... tion-class


Top
 Profile  
 
 Post subject: It's the thing
PostPosted: Fri Dec 02, 2005 3:56 am 
Newbie

Joined: Wed Nov 30, 2005 1:59 pm
Posts: 2
It's the thing I was looking for thatnks.


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