GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes How To know data  saved or  updated in hibernate session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How To know data  saved or  updated in hibernate session" Watch "How To know data  saved or  updated in hibernate session" New topic
Author

How To know data saved or updated in hibernate session

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
how you know data is updated or saved or deleted in database in hibernate session
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Check the data programatically?

Not sure I understand why you need to know if it;s an update or an insert - the Hibernate API can be used transparently for either. A delete you will know about, because your code will have deleted an object.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Craig Taylor
Ranch Hand

Joined: Jul 17, 2008
Posts: 64

Check the id to see if the data has previously been persisted to the database - if it has not then you know it needs to be saved.

Attempt to re-fetch the data based upon it's id; if it doesn't exist then your application (or another) has deleted it - otherwise it's an update if the fetched data and current data differ.

Note : Your question is of the nature that often is because of other problems you're handling ... Why do you want to / need to know?
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I am newbie to hibernate. My interviewer asked this question . How you know whether data saved inserted or deleted. what should i reply
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
in hibernate session
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To know data saved or updated in hibernate session