-->
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: Invalid sql generated for update
PostPosted: Wed Apr 15, 2009 1:44 pm 
Newbie

Joined: Wed Sep 10, 2008 2:02 pm
Posts: 14
Location: NJ
Hibernate is generating invalid sql for a named query that's attempting to do an update. I have other similar named queries that work fine. Don't know what's going on here.
I will be happy to provide whatever other information is necessary to help resolve the issue.
It might be hard to spot the problem, so I'll just include the fact that a comma follows the name of the table to be updated in the generated sql:
update media, set is.....
Thanks for any insights.

Hibernate version:
core: 3.2.6ga
entity manager: 3.2.2.ga
annotions 3.2.1.ga

Mapping documents:
Quote:
<query name="Medium.SetCoversUnavailable_movie_inStockOn_region">
<![CDATA[update Medium m set m.isCoverAvailable = 'false' where
m.movie = :movie and m.dateInStock = :inStockOn and
m.purchaseOrder.shipToRegion = :region]]>
</query>


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

Full stack trace of any exception that occurs:

Name and version of the database you are using:
PostgreSQL 8.?

The generated SQL (show_sql=true):
Quote:
2009-04-15 13:25:24,395 DEBUG [org.hibernate.SQL] update media, set isCoverAvai
lable='false' where movieid=? and dateInStock=? and shipToRegion=?


Debug level Hibernate log excerpt:
Quote:
2009-04-15 13:25:24,390 TRACE [org.hibernate.engine.query.HQLQueryPlan] executeUpdate:
update Medium m set m.isCoverAvailable = 'false' where
m.movie = :movie and m.dateInStock = :inStockOn and m.purchaseOrder.shipToRegion = :region
2009-04-15 13:25:24,390 TRACE [org.hibernate.engine.QueryParameters] named parameters: {inStockOn=26 February 2009, movie=com.nym.session.common.Movie#4203, reg
ion=com.nym.hbm.model.Region#1}2009-04-15 13:25:24,393 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open
PreparedStatement (open PreparedStatements: 0, globally: 0)2009-04-15 13:25:24,393 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDB
C connection2009-04-15 13:25:24,395 DEBUG [org.hibernate.SQL] update media, set isCoverAvai
lable='false' where movieid=? and dateInStock=? and shipToRegion=?2009-04-15 13:25:24,395 INFO [STDOUT] Hibernate: update media, set isCoverAvai
lable='false' where movieid=? and dateInStock=? and shipToRegion=?


Top
 Profile  
 
 Post subject: I think I understand, but I'm surprised by the result
PostPosted: Wed Apr 15, 2009 3:04 pm 
Newbie

Joined: Wed Sep 10, 2008 2:02 pm
Posts: 14
Location: NJ
I think I understand why the problem occurs, but I would expect different behavior from Hibernate.
The named query tries to update based on a join (medium.purchaseOrder.shipToRegion) and this obviously doesn't work. As you all may have guessed, I'm no SQL expert.


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.