-->
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: Problem with invalid SQL when using joins
PostPosted: Fri Mar 31, 2006 9:04 am 
Newbie

Joined: Mon Dec 01, 2003 10:23 am
Posts: 7
Hibernate version:
3.1.3

Name and version of the database you are using:
MySQL 5.0.19

HQL:
SELECT o.id FROM Release o JOIN o.shop s JOIN s.resellers r WITH r.id = :shopId WHERE o.id = :releaseId AND o.released <= :now

The generated SQL (show_sql=true):
select release0_.id as col_0_0_ from ContentItem release0_ inner join Shop shop1_ on release0_.shopId=shop1_.id inner join Reseller resellers2_ on shop1_.id=resellers2_.shopId and inner join Shop resellersh3_ on resellers2_.resellerShopId=resellersh3_.id and (resellersh3_.id=?) where release0_.type='Release' and release0_.id=? and release0_.released<=?

Somehow Hibernate adds an "and" in the join clause which causes a syntax error. Any clues on how to solve this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 10:20 am 
Newbie

Joined: Mon Dec 01, 2003 10:23 am
Posts: 7
Ok, I found the cause. I had an unused empty where clause in my mapping.


Code:
<set name="resellers" table="Reseller" order-by="id asc" cascade="none" where="">
      <key column="shopId"/>
      <many-to-many column="resellerShopId" class="ResellerShop"/>
</set>


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.