-->
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: translate sql (from mysql) to hql
PostPosted: Mon Dec 13, 2004 12:18 pm 
Newbie

Joined: Mon Nov 17, 2003 7:35 am
Posts: 5
hi,

I have a problem to translate this sql to hql:

Code:
select l.loan_id as loan,
       p0.amount as amount,                                                                                           
       sum(p1.amount) as amountPayed
from loans l                       
        inner join account_histories p0
        on l.loan_id = p0.loan         
           left outer join account_histories p1
           on l.loan_id = p1.loan and p1.from_account = 1945
where p0.to_account   = 1945 and p0.from_account = 1
group by l.loan_id


this code is what I have for now, but doesn't work.. when I have a "Loan" and this one have no "payments", hibernate ignores that

Code:
select
    l.id,
    p.amount,
    sum(p1.amount)
from
    Loan l inner join l.loanPayments p left join l.loanPayments p1
where (p.from.id=1 and p.to.id = 1945) and p1.from.id = 1945
group by l


somebody can help me?

.. sorry my english ..


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.