-->
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: Load same Entity(same DB identity) in session >1 time
PostPosted: Fri Apr 15, 2005 5:59 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
I am using hibernate 3.0 final.

This is a design question so I am not sure any of the requested information is needed. If it is needed I can add it to the post.

I am trying to load an entity twice in a same session. Here is what is going on.

- open session s
- I first load entity of type com.mycompany.MyEntity with db id 100 using session s
- i update one of the associations/properties of the entity
- I then call update (say on a DAO layer from a higher layer) with that same entity (NOTE: session is still open using ThreadLocals)
- in the update code I try to discern if a particular property changed so I can create an arhive entry for it using its old value (currently in the db).
THis last step is proving a little tricky as the first level cache is not allowing me to get a fresh copy of the entity from the database.
I would like to be able to tell the session to load the same entity even if it already exists in the session cache. Can this be done or do I have to open a new session?

My other question is on the approach.
What is the best way to do this? Should I use interceptors or is there a better strategy to handle archiving row state before an update?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 17, 2005 2:31 am 
Newbie

Joined: Tue Apr 05, 2005 8:01 am
Posts: 12
To answer your question logically, increasing the isolation level to READ_COMMITED may do the trick.

NOTE : I am under the assumtion that you have not yet commited the transaction after update.


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.