This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Why update() is necessary? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Why update() is necessary?" Watch "Why update() is necessary?" New topic
Author

Why update() is necessary?

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hi.
If we have a detached object and want to reconnect it to Session, we call update() method.
But really, why this is necessary? I mean what happens under the hood?
Thanks.
Walter Bernstein
Ranch Hand

Joined: Dec 19, 2007
Posts: 57
"What happens under the hood?"

=> your object gets reconnected/attached to the current hibernate session.
=> at some point hibernate tries to update your object in the db.

I prefer session.lock() to reconnect a object.
Walter Bernstein
Ranch Hand

Joined: Dec 19, 2007
Posts: 57
"But really, why this is necessary?"

=> If an object is not connected to a hibernate session, it is not managed by hibernate. So any change to your object will not be persisted.
[ December 26, 2007: Message edited by: Walter Bernstein ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why update() is necessary?
 
Similar Threads
Question on @Resource Annotation
regarding the static
Why Hibernet
Exception on calling wait() method of Object class(WHY)
Motif, Metal or Window ???????????