learn java
The moose likes Object Relational Mapping and the fly likes HQL query with OneToMany 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 with OneToMany" Watch "HQL query with OneToMany" New topic

HQL query with OneToMany

Kamil Kuchta

Joined: Mar 09, 2009
Posts: 17
I have problem to create some HQL query.
This is my object model. Hotel has list of Image.

Standard SQL in this case is easy:

But how to create HQL?
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3881

Isn't the relationship bi-directional? You have to reference Hotel from the Image as Many side of One-To-Many will be the owner of the relationship. HQL is bit different form SQL. Are you trying to execute a native SQL or HQL?

[How to ask questions] [Twitter]
Have you tried LearnNowOnline? http://www.learnnowonline.com/
subject: HQL query with OneToMany