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: session.update & saveOrUpdate
PostPosted: Fri Nov 23, 2007 5:56 am 
Beginner
Beginner

Joined: Thu May 17, 2007 9:56 am
Posts: 21
Location: India
Hi,
We are using hibernate 3.0.
We are using session.saveOrUpdate to insert a new value into the database & to update the existing entry.
So, if the searched value which is to be updated is unavailable that value will be inserted into the table.

But if we don't want to insert a new record & we want only a pure update, then we are using HQL queries. (HQL update queries).

Is it possible to update the record only & not to give a new entry if the searched value is not found using session.update? Else, here also new row will be inserted or not? Any disadvantages over session.update?

I want to know the advantages & disadvantages of session.update before using it.

Thanks in advance,
Kuzhali

_________________
Kuzhali


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 7:54 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

session.save
will give you back the identifer(PK) after saving it to the database.

session.update
If the Object should have PK, then the record will be updated into database.

session.saveOrUpdate
If the identifer(PK) exists in the Object the record will be updated else new record would be created.

Feel free to use this to your requirements.

Hope this helps!!!

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


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.