-->
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.  [ 6 posts ] 
Author Message
 Post subject: Refresh of item fails to remove newly added entries in Sets?
PostPosted: Fri May 25, 2007 11:00 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
Hibernate version:
3.0.5
Mapping documents:
Irrelevant
Code between sessionFactory.openSession() and session.close():
load an object
modify it, add new items to a Set
ask for session.refresh() to cancel change
Full stack trace of any exception that occurs:
Code:
Caused by: org.hibernate.HibernateException: this instance does not yet exist as a row in the database
   at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:77)
   at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:679)
   at org.hibernate.engine.Cascades$3.cascade(Cascades.java:112)
   at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
   at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
   at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:819)
   at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:85)
   at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:679)

Name and version of the database you are using:
Oracle 9

The generated SQL (show_sql=true):
none

Hello,

I have a class which contains some sets (one-to-many contraints). The user modify at will the object, add items to set, remove items, etc, but does not flush nor save the object. Because user wants to cancel changes, we issue a session.refresh(manipulatedObject). While we would expect the object to get back to database state (same is if it was not cached in session and we issued a session.load(id) ) it does not refresh() properly.
How can we reset the object to it's database state, including all object linked via Sets?

Thanks for help.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 26, 2007 10:23 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
I assume no commit has been done? If that's the case you can simply do a session.clear() and then close the session.

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 3:41 am 
Senior
Senior

Joined: Tue May 10, 2005 9:00 am
Posts: 125
We are in the context of a webapp. We associate one hibernate session per user http session. We disconnect/reconnect session at each request. Doing a session.clear() and a close() would cause trouble to other forms using hibernate object, as they won't be able to run their lazy loaders. Assume i got an object A linked in user session, not related to the object X i want to reset now, if i do a session.close(), i won't be able to call safetly methods on A anymore. Keeping track off all hibernate loaded objects in user session and invalidating them when session.close() would be a hard work. I only want to reset object X, it's 1-0..n relations (datas specifically part of object X and not used anywhere else).


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 4:19 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

try session.get(id) insteadof session.load(id)


Amila

(Don't forget to rate if helps)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 04, 2008 10:41 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
amila733 wrote:
Hi

try session.get(id) insteadof session.load(id)


Amila



This doesn't help, because it hits only the first level Cache i.e. the session.

Did anybody find a solution to this problem? I'm considering rewriting the DefaultRefreshEventListener to solve this problem.

Is this a bug or is there a reason for this behaviour?

Jens

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 04, 2008 11:54 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
I just found this:
http://opensource.atlassian.com/project ... e/HHH-2643

So all we are going to get might be a clarification in the documentation. :(

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.