-->
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.  [ 7 posts ] 
Author Message
 Post subject: Duplicating of data.
PostPosted: Mon Jan 14, 2008 12:56 pm 
Newbie

Joined: Mon Jan 14, 2008 6:29 am
Posts: 7
I have the following problem:

There is a base class 'A' and its inheritor one 'B'.
These classes are both mapped on the table 'C'.

Supposed, there are two records in the table 'C'.

If we select data of objects 'A' we get 4 records.
although we get 2 records for the objects 'B'.

What may problem be in ?
Note: I'm using NHibernate 1.2
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:17 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
I assume you don't have a discriminator value:

when selecting A you select A and all inheritors, since your table contains two rows which (i assume can be both A's and B's) it returns 2 A instances and 2 b instances. The same result would you get if you did for instance:

Code:
from object


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:34 pm 
Newbie

Joined: Mon Jan 14, 2008 6:29 am
Posts: 7
How can i resolve this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:38 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
In my book it isn't a "problem" its just how polymorphism works :-)

But for performanceoptimizations you can take a look at the suggestions in this post:

http://forum.hibernate.org/viewtopic.ph ... 56#2373556


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:40 pm 
Newbie

Joined: Mon Jan 14, 2008 6:29 am
Posts: 7
I need to get 2 records for 'A' and 'B' objects (


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:46 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
An instance of B is also of type A as far as i known HQL queries don't have any operators to ensure that you only get superclass'es. Try reading chapter 11.6 in the nHibernate reference manual


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 2:12 pm 
Newbie

Joined: Mon Jan 14, 2008 6:29 am
Posts: 7
Thanks for your quickly answering my question.
You clarified a lot of nuances.


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