-->
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: Multilevel association HQL query issue
PostPosted: Tue Mar 03, 2015 4:01 am 
Newbie

Joined: Fri Feb 27, 2015 6:45 am
Posts: 3
I have entity Customer, Order, Line Item, Status, Currency
These entities has one way relationship wither entities.

Customer has Order entity and this is One to one relation ship and it is one way relation ship from Customer to Order. (Customer has One Order)

Order has Line item entity and this is One to one relation ship and it is one way relation ship from Order to Line Item. (Order has one Line Item)

Order has Currency Entity and this is Many to One relation ship and it is also one way relation ship from Order to Currency (Many Order has one Currency)


Customer has Status Entity and this is Many to One relation ship and it is also one way relation ship from Customer to Status (Many Customer has one Status)


SELECT DISTINCT customer,1
FROM Customer customer
RIGHT OUTER JOIN customer.order order
JOIN order.currency as currency
Where order.id = :ORDER_ID.

This above query generates 3 queries behind the scene.
Could anybody help on how to write query that gets Customer,Order,LineItem,Currency,Status
in single HQL.


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.