-->
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.  [ 2 posts ] 
Author Message
 Post subject: Left Join in the Hibernate Query
PostPosted: Sat Nov 12, 2005 12:46 am 
Newbie

Joined: Mon Jul 18, 2005 5:44 am
Posts: 3
hi all ,

I have 2 tables, one is Package another is Product .
Package not nescessary have product , so generally when we using
sql , we will left join product with the package in order to view
the record of package even though there are no product link with it.

Question is , in the HQL , can we use left join for the same purpose?

if can , when i code like this
-------------------------------------------------------------------------------------
[CODE]
queryString.append("select package.name, package.price from Product as product LEFT JOIN Package as package on package.Id = product.PackageId");
Lsit 1 = session.createQuery(queryString.toString().list());
[CODE]
-------------------------------------------------------------------------------------

my mapping file is like this
-------------------------------------------------------------------------------------
[for the association in Package.hbm]
<set inverse="true" name="ProductSet">
<key column="bi_package_id" />
<one-to-many class="Product" />
</set>

[for the association in Product.hbm]
<many-to-one
class="Package"
name="PackageId"
not-null="true"
>
<column name="bi_package_id" />
</many-to-one>

-------------------------------------------------------------------------------------

but it throw me the exception:
[CODE] net.sf.hibernate.QueryException: outer or full join must be followed by path expression


Can someone help me with this. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 12, 2005 1:42 am 
Newbie

Joined: Mon Oct 31, 2005 4:01 am
Posts: 2
Try using the following HQL query

select package.name, package.price
from
Package package
LEFT JOIN package.ProductSet


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.