-->
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: Updating row with createSQLQuery
PostPosted: Tue Sep 22, 2009 6:24 pm 
Newbie

Joined: Wed May 13, 2009 4:11 pm
Posts: 2
I am trying to update a row in my table using createSQLQuery, because my row contains a column of SDO_GEOMETRY type that Hibernate doesn't support. However, when I run the executeUpdate() and commit the transaction, my database is not updated and I don't get any exceptions to explain why it wasn't updated. It just looks like it was committed correctly. This is what my code looks like:

Code:
String sqlString = "update GEOM set geo_points=SDO_UTIL.CIRCLE_POLYGON(50,-150,300,3) where id=105";
Transaction tx = session.beginTransaction();
SQLQuery query = session.createSQLQuery(sqlString);
query.executeUpdate();
session.flush();
tx.commit();


I can successfully run the same snippet of code with an INSERT rather than an UPDATE.

What am I missing?


Top
 Profile  
 
 Post subject: Re: Updating row with createSQLQuery
PostPosted: Tue Sep 29, 2009 6:30 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 6:39 am
Posts: 44
Location: Mumbai, India
make show_sql as true and find the sql query for update in console.

_________________
Thx,
Murugesan.
Web: http://www.murugesanpitchandi.com


Top
 Profile  
 
 Post subject: Re: Updating row with createSQLQuery
PostPosted: Wed Sep 30, 2009 8:33 am 
Newbie

Joined: Wed May 13, 2009 4:11 pm
Posts: 2
Setting show_sql to true displayed the correct query when I did the query.executeUpdate() line, but then it cleared everything out when I did a session.flush().

The solution to this was to do a session.refresh() and then a tx.commit().


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.