-->
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: Please convert this SQL query to hibernate
PostPosted: Mon May 24, 2010 1:08 pm 
Newbie

Joined: Thu May 06, 2010 6:35 am
Posts: 3
Hi Guys,

Please help me to write this SQL query to HQL..

Code:
SELECT acc.*, t.total FROM account as acc
JOIN (SELECT tx.msisdn as msisdn, sum(tx.amount) as total FROM accrued_transaction tx WHERE tx.year = 2010 AND tx.quarter = 2 AND (tx.opted_in is null OR tx.opted_in = 1) GROUP BY tx.msisdn) t ON t.msisdn = acc.msisdn
WHERE acc.account_group = 300
and acc.opt_in_date is null


Thanks in advance


Top
 Profile  
 
 Post subject: Re: Please convert this SQL query to hibernate
PostPosted: Tue May 25, 2010 6:26 am 
Newbie

Joined: Thu May 06, 2010 6:35 am
Posts: 3
i have written like this
Code:
select acc, sum(tx.amount) FROM Account acc
         "INNER JOIN AccruedTransaction tx on acc.msisdn = tx.account.msisdn WHERE
acc.group = :group and acc.optInDate is null and tx.year <= :year AND tx.quarter <= :quarter AND (tx.optedIn is null OR tx.optedIn = :lapsedOrOptedIn) GROUP BY tx.msisdn, acc.msisdn"


but it gives the error exactly at the ON class, please some one help me to solve this


Top
 Profile  
 
 Post subject: Re: Please convert this SQL query to hibernate
PostPosted: Tue May 25, 2010 8:40 am 
Newbie

Joined: Mon May 24, 2010 2:47 pm
Posts: 3
I think you should check class. There is wrong relationship given. So problem is created. And you should also check parameters.

_________________
iedge


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.