-->
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: Bad SQL generated from update query expression
PostPosted: Thu Jul 12, 2007 3:33 am 
Newbie

Joined: Fri Sep 03, 2004 10:53 am
Posts: 7
Hibernate version: 3.2.4SP1 with 3.3.1GA EntityManager and 3.3.0GA Annotations

Name and version of the database you are using: Postgresql 8.2

The generated SQL (show_sql=true):
update PERSON set NAME=? where (ID in (select company1_.ID from COMPANY company1_ )) and person0_.NAME<>?


I think I've found a bug in the SQL generation for update queries in EJBQL.

My query is:
update Person set name = ?1 where id in (select c.id from Customer c)
and name <> ?2

The generated SQL refers to an unknown table alias "person0_".

If I change around the conditions in the where clause, then the problem goes away. That is:

update Person set name = ?1 where name <> ?2 and id in (select c.id from Customer c)

does not generate bad code.

Also, if I add a where clause to the inner select, then the problem also goes away.

Finally, correct SQL is generated in the matching select.

Is this a known bug? Or should I add it to JIRA?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 8:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please add it to JIRA in the Hibernate3 project.
A test case would be apreciated.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 10:33 am 
Newbie

Joined: Fri Sep 03, 2004 10:53 am
Posts: 7
I added this issue to JIRA:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-2724

The test classes are about as small as I could make them. Best of luck solving the problem.


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.