aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
regarding the static
Why Hibernet
Question on @Resource Annotation
Exception on calling wait() method of Object class(WHY)
Motif, Metal or Window ???????????