-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to write a Outer join Query in HQL
PostPosted: Sat Mar 29, 2008 2:23 am 
Newbie

Joined: Fri Dec 07, 2007 9:25 am
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2.2

Mapping documents:
Training.xml

<hibernate-mapping>
<class name="TrainingHB" table="TRAINING">

<id column="TRNG_ID" name="trngId" length="64" type="java.lang.String"></id>

<property column="TRNG_TRAINEE_ID" length="64" name="traineeId" not-null="true" type="java.lang.String"/>
<property column="TRNG_TRAINED_NODE_ID" length="64" name="trainedNodeId" not-null="true" type="java.lang.String"/>
</class>
</hibernate-mapping>


EmployeeWorkDetails.xml

<hibernate-mapping>
<class name="EmployeeWorkDetailsHB" table="EMPLOYEE_WORK_DETAILS">
<id column="EWD_ID" name="ewdId" length="64" type="java.lang.String"></id>

<property column="EWD_EMP_ID" length="64" name="empId" not-null="true" type="java.lang.String"/>
<property column="EWD_SHIFT_ID" length="64" name="shiftId" type="java.lang.String"/>
</class>
</hibernate-mapping>

Station.xml

<hibernate-mapping>
<class name="com.visiontss.muis.model.hb.StationHB" table="STATION">

<id column="STN_ID" name="stnId" length="64" type="java.lang.String"></id>

<property column="STN_NODE_ID" length="64" name="nodeId" not-null="true" type="java.lang.String"/>
<property column="STN_NAME" length="64" name="name" not-null="true" type="java.lang.String"/>
<property column="STN_TRAINING_FLEX_INDEX" name="trainingFlexIndex" type="int"/>
</class>
</hibernate-mapping>


Node.xml

<hibernate-mapping >
<class name="NodeHB" table="Node">

<id column="NODE_ID" name="nodeId" length="64" type="java.lang.String" />

<property column="NODE_PARENT_NODE_ID" length="64" name="parentNodeId" not-null="true" type="java.lang.String"/>


<property column="NODE_NAME" length="64" name="nodeName" not-null="true" type="java.lang.String"/>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

query= "select count(t.trainedNodeId), n.name, s.trainingFlexIndex"
+ " from StationHB s left outer join TrainingHB t"
+ " with s.nodeId = t.trainedNodeId"
+ " inner join NodeHB n"
+ " with n.nodeId = s.nodeId"
+ " left outer join EmployeeWorkDetailsHB ewd"
+ " and ewd.empId=t.traineeId"
+ " group by t.trainedNodeId,n.name,s.trainingFlexIndex"
+ " having (count(t.trainedNodeId)-s.trainingFlexIndex<=0) ";



Full stack trace of any exception that occurs:
[3/29/08 11:36:05:969 IST] 00000029 PARSER E Path expected for join!
[3/29/08 11:36:06:000 IST] 00000029 PARSER E Path expected for join!
[3/29/08 11:36:06:109 IST] 00000029 PARSER E Invalid path: 't.trainedNodeId'
[3/29/08 11:36:06:156 IST] 00000029 PARSER E Invalid path: 'n.name'
[3/29/08 11:36:06:203 IST] 00000029 PARSER E Invalid path: 't.trainedNodeId'
[3/29/08 11:36:06:234 IST] 00000029 PARSER E Invalid path: 't.trainedNodeId'

Name and version of the database you are using:
IBM DB2 UDB (8.1)


The generated SQL (show_sql=true):NIL

Debug level Hibernate log excerpt:NIL


Problems with Session and transaction handling? NO

Read this: http://hibernate.org/42.html


I am working in Hibernate for the past 4 months. Need some guidance how to apply the Outer joins in HQL.

If any piece of sample code will help me to understand better


Thanks
Raji.T


Top
 Profile  
 
 Post subject: Re: How to write a Outer join Query in HQL
PostPosted: Mon Mar 31, 2008 4:09 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Raji, I don't believe this is going to work in HQL. You need to use a native query to do this and use transformers to turn the results into entities. However, I might be wrong saying you can't do this with HQL.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 7:11 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

there are many joins in your hql. Please add one by one until you get the error. so you can identify where is the error and can focus to it.

if you send java codes and othere nessary details i will look in details.


Amila
(Don't forget to rate if helps)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.