File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Please help me to convert this SQL to hibernate query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Please help me to convert this SQL to hibernate query" Watch "Please help me to convert this SQL to hibernate query" New topic
Author

Please help me to convert this SQL to hibernate query

Pattamuthu Aru
Greenhorn

Joined: May 25, 2010
Posts: 13
select a.msisdn,sum(b.amount) 'amount'
from account a
inner join accrued_Transaction b on a.msisdn = b.msisdn
where a.account_group = 300 and a.opt_in_date is null and b.year <= 2010
AND b.quarter <= 2 AND (b.opted_in is null OR b.opted_in = 1)
GROUP BY b.msisdn, a.msisdn


HQL seems to be not accepting ON class

Thanks in advance
Sue Temple
Greenhorn

Joined: May 01, 2010
Posts: 19
If your sql works correctly, please ensure that you have the mapping classes right

Hql -
Pattamuthu Aru
Greenhorn

Joined: May 25, 2010
Posts: 13
i tried the same but it gave me exception

The named query in account


And the exception is



MY actual SQL query which it seems to work with out any error is like this, so if we able to convert this query in HQL, then it will be good
Pattamuthu Aru
Greenhorn

Joined: May 25, 2010
Posts: 13
Any suggestions or help, please.

Bringing to top
Pattamuthu Aru
Greenhorn

Joined: May 25, 2010
Posts: 13
Atleast someone please help me to convert this SQL query to Hibernate native query


i have just copy pasted this SQL in java but even then it doesnt work says



Please thanks in advance
Cj Recto
Greenhorn

Joined: Mar 02, 2012
Posts: 26
There's no problem in your query, the problem is with your mapping file I had the same problem before when it comes to joining table.
this link solved my problem in mapping files for joined table.

java4s Join

see if it'll work for you.
Mahendr Shinde
Ranch Hand

Joined: Sep 03, 2011
Posts: 38

You can try Native SQL Query if your SQL query works


There is still lot to learn!
 
wood burning stoves
 
subject: Please help me to convert this SQL to hibernate query