-->
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.  [ 5 posts ] 
Author Message
 Post subject: saveOrUpdate only generates select query, no insert or updat
PostPosted: Wed Jan 07, 2009 9:05 am 
Newbie

Joined: Fri Mar 23, 2007 4:47 am
Posts: 16
Hi All,

I am trying to save a object using saveOrUpdate. I have set show_query to true and I see all the executed queries in my website log. When saveOrUpdate is executed, I see a select statement in the log but no update pr insert command.

The select statement is executed to see if the object exists in the database. I can confirm that the object already exists so after the select statement a update query should be executed but it isn't.

Anybody with a idea what could be causing this?

Martyn


Top
 Profile  
 
 Post subject: Hi
PostPosted: Wed Jan 07, 2009 9:32 am 
Beginner
Beginner

Joined: Wed Nov 26, 2008 1:02 am
Posts: 22
hi,
I think you are not modifying the object extracted from database,if you are using saveOrUpdate(notModifiedObject) will execute only Select not an update ,check this

regards

_________________
if it solves,rate me


Top
 Profile  
 
 Post subject: saveorUpdate generates select.. for update..
PostPosted: Mon Feb 09, 2009 12:38 pm 
Newbie

Joined: Mon Feb 09, 2009 12:20 pm
Posts: 2
Location: Ukraine
Hi.

I had the same problem as above - it really was with not modified object. But now a have another thing:
when a call saveOrUpdate(myObject), Hibernate generates query as next:

select user_id from user_settings where user_id =? for update

And nothing else. Db is not updated.
Can you help me how to resolve it?

..
I also tryed to add LockMode, but it did not helps too.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2009 6:49 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
make sure that you commit your transaction. If you don't do this it won't save to the database.


Top
 Profile  
 
 Post subject: resolved
PostPosted: Tue Feb 10, 2009 5:48 am 
Newbie

Joined: Mon Feb 09, 2009 12:20 pm
Posts: 2
Location: Ukraine
heh :)

i forgot to add @Transactional declaration :)

now it's working ok


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