-->
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: Finding the original object loaded from dbase by hibernate
PostPosted: Thu Jul 07, 2005 5:07 pm 
Newbie

Joined: Wed Jun 22, 2005 9:03 am
Posts: 4
Hi All,

I could not find any documentation related to this. We are migrating an existing Toplink application to hibernate. In the current application once we read any persisted object from the database through Toplink (which makes a backup of read object and refers to it as original Object).
The persisted object is cloned and given to the calling application. The application uses this cloned object and makes changes to this object, however Toplink always maintains an untouched original object. When this object is saved through Toplink it will be compared with the original object and the new clone will be saved.

The above is termed as inspection in Hibernate (or ORM terms). Which is very similar to what Toplink does. But somehow our application needs the original object to make some decision of our own. So toplink provides us with an API where we can give the (clonedObject) and it will return us the unmodified version of object that was read from database intially.

I have seen lot of references to findDirty and dirtychecking, but I am not sure if it will get us the original copy if we give the clone. I know from documentation that hibernate does maintain the original copy, is there an easy way to retreive it , either by classname its id or some other means.

I appreciate all the help in advance.

Hibernate version:
[INFO] Environment - Hibernate 3.0.5


Mapping documents:
not needed

Code between sessionFactory.openSession() and session.close():
not needed

Full stack trace of any exception that occurs:
not needed

Name and version of the database you are using:
not needed

The generated SQL (show_sql=true):
not needed

Debug level Hibernate log excerpt:
not needed

_________________
Amish Shah
OPNET Technologies


Top
 Profile  
 
 Post subject: Please can someone reply to it
PostPosted: Mon Jul 11, 2005 1:39 pm 
Newbie

Joined: Wed Jun 22, 2005 9:03 am
Posts: 4
I do see one relevant topic raised by Partick Bradley on Monday Feb 16, 2004, under the topic Reconstructing original Object from Interceptor's flushDirty.

Would like to explore if there are other easier ways of doing it.
I can think two more indirect way of doing it.
a) Looks like org.hibernate.event.MergeEvent used in SessionImpl does have a way to get original, but I am not sure how to really use it.

b) Other way was probably use getDatabaseSnapshot but still that will not be that straightforward.

If anybody from hibernate team can think of anything that can help us.
Of course we can always do one option is before we make changes to our persistent model object, we can clone ourselves and use that later on.

regards
Amish

_________________
Amish Shah
OPNET Technologies


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.