-->
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.  [ 1 post ] 
Author Message
 Post subject: help with left outer join in hibernate
PostPosted: Mon Jun 05, 2006 1:36 pm 
Newbie

Joined: Mon Jun 05, 2006 1:33 pm
Posts: 1
Hi,

I am using hibernate2. I want
to do a left outer join but I am not able to form hql
properly. I am writing both sql and hql version of
what I am doing. While sql gives the correct results,
HQL gives the total sum instead of grouping by
PurchaseReqNo.

Could someone tell me what I am doing wrong. Any
help will be appreciated.

SQL
------
select V.purchasereqno,v.vendorname,v.justification,
v.datecreated,sum(c.amount)
from voucher v, commodityinfo c
where v.purchasereqno=c.purchasereqno(+)
group by
c.purchasereqno,v.justification,v.datecreated,v.vendorname

HQL
------
String sql = "select new
Voucher(V.purchasereqno,v.vendorname,v.justification,
v.datecreated,sum(c.amount)) " +
" from Voucher v, " +
" CommodityInfo c left outer join
c.purchaseReqNo as purchaserReqNo " +
" group by
v.purchasereqno,v.vendorname,v.justification,
v.datecreated,sum(c.amount)";
return getHibernateTemplate().find(sql);

Thanks,

Pankaj


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.