Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Object Relational Mapping and the fly likes HQL query related to many-to-many relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "HQL query related to many-to-many relationship " Watch "HQL query related to many-to-many relationship " New topic
Author

HQL query related to many-to-many relationship

Shanika Weerapperuma
Greenhorn

Joined: Jun 28, 2004
Posts: 26
Hibernate version: 2.1.7c

I'm having a problem in getting the proper HQL for the follwong senario:

I have done the many-to-many relationship mapping. (In this, the ITEM has a set of Orders and The Orders has a set of Items)
ITEM is defined as the inverse end. The records for ITEM_ORDER table gets inserted when calling the session.save(order) and works fine.


Now, how to write the HQL to find out all the Orders objects that contains Item "ITM_01" ? In other words, i need to get all the Orders objects, that has Item "ITM_01" in their Item set.

please help.
Shanika Weerapperuma
Greenhorn

Joined: Jun 28, 2004
Posts: 26
oh, i found it and so impressed to see how simple it is :



 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: HQL query related to many-to-many relationship