Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes hibernate left join not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate left join not working" Watch "hibernate left join not working" New topic
Author

hibernate left join not working

Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
I use the following query in Hibernate for a left join between table1 and table2.



Can someone help me with this.
[ October 21, 2005: Message edited by: mannu kapoor ]
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
Do your mapping files have an association defined between objects table1 and table2? If not that could be your issue.
Lucian Ochian
Greenhorn

Joined: Nov 23, 2004
Posts: 7
The way that you wrote the query it seems to be an SQL query and not an HQL query.
Using session.createQuery, you need to provide to this method a HQL query, and not a SQL query.
You can use session.createSQLQuery with a SQL query, or write your query as a HQL query, something like:

select cv.field from table1 alias1 JOIN alias1.x alias2, where x is your association element in the first class.

Hope this helps!
[ November 16, 2005: Message edited by: Lucian Ochian ]
 
Don't get me started about those stupid light bulbs.
 
subject: hibernate left join not working
 
Similar Threads
inner join Vs outer join
How do I map this?
Hibernate: Different Join in Save() and Get()
Mysql query
Hibernate one-to-many, one-to-one association not selecting records without children