-->
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.  [ 4 posts ] 
Author Message
 Post subject: Named queries return duplicate rows with object inheritence
PostPosted: Mon Oct 23, 2006 10:40 pm 
Newbie

Joined: Tue Aug 01, 2006 5:19 pm
Posts: 3
We have some special cases due to which we had to use this approach.

I have a 'Vendor' object which is a persistent class in hibernate mappings.

<hibernate-mapping package="com.verisign.vps.common.model">
<class
name="Vendor"
table="VENDORS"
>

I have 'UnifiedVendor' object extending 'Vendor' object. UnifiedVendor is also persistent in database.
hibernate-mapping package="com.paypal.vps.common.model">
<class
name="UnifiedVendor"
table="VENDORS"
>

Both pointing to same table. So if I run a named query like this
'select vendor from Vendor vendor where vendor.name = :vendorName'. It is running two queries against database

Hibernate: select vendor0_.VID from PAY.VENDORS vendor0_ where (vendor0_.NAME=? )

Hibernate: select unifiedven0_.VID as VID26_ from PAY.VENDORS unifiedven0_ where (unifiedven0_.NAME=? )

Result has two duplicate rows while I am expecting it to run just once.
Is there any work around for this, other than using SQL queries?

Thank you in advance.
taraka


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 12:15 am 
Regular
Regular

Joined: Wed Jul 27, 2005 2:33 am
Posts: 118
Try setting polymorphism="explicit" in the Vendor.hbm.xml at class level.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 12:42 am 
Newbie

Joined: Tue Oct 17, 2006 10:57 am
Posts: 14
what happens if you use
GeneralCriteriaCallback callback = new GeneralCriteriaCallback(
vendor.class);
.
.
.
.
.
getHibernateTemplate().execute(callback);

are u saying even the above statements run the sql twice?


Top
 Profile  
 
 Post subject: It works
PostPosted: Tue Oct 24, 2006 5:05 pm 
Newbie

Joined: Tue Aug 01, 2006 5:19 pm
Posts: 3
It worked by putting polymorphism="explicit".

Thank you very much
taraka


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