This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Join query in HQL 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 "Join query in HQL" Watch "Join query in HQL" New topic

Join query in HQL

Shinu Pil

Joined: Sep 02, 2005
Posts: 9

i have two tables abc and device

my mapping file of abc i added

<many-to-one name="device" class="com.model.device" cascade="all" >
<meta attribute="default-value">new Device()</meta>
<column name="deviceId" />
My requirement is that when user search for deviceName from the uI it will fetch data first table and corresponding employee id assigned.If it not assigned need to return null value

How written in hibernate....

i written sample query in mysql it will work fine but i donot know how convert thta into HQl
It is the mysql query

i wriiten corresponding hQL as

i got following exception

rg.hibernate.hql.ast.QuerySyntaxException: unexpected token: from near line 1, column 76 [ ]

please help on this
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

it should be

This post show how to work with JPQL/HQL:

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Shinu Pil

Joined: Sep 02, 2005
Posts: 9
i resolved this pblm by giving
select abc from ABC ABC LEFT JOIN abc.device
right now i getting results when matching records found in both tables ,but if there is no empid is not in abc and records are in device it not displayed.....wht will do in this situation i tried right join also but no chance to get results.Any help really appreciated..
I agree. Here's the link:
subject: Join query in HQL
Similar Threads
hibernat creating the tables without cascade
Difference in session.createQuery() and session.createSqlQuery()
HQL query required with left outer join
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient
i have a Errors in Hibernate Query