-->
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: How to discard changes on detached objects?
PostPosted: Tue May 29, 2007 6:17 am 
Beginner
Beginner

Joined: Sat Feb 10, 2007 12:18 pm
Posts: 23
Hi

I am writng an eclipse RCP and my objects are detached most of the time. i only call an update when I want to save an object. But how can I reestablish the persistence from the database for a single, detached object? This would make my code much easier when the user discards the changes made to an object.

Thx


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 1:26 pm 
Beginner
Beginner

Joined: Sat Feb 10, 2007 12:18 pm
Posts: 23
No one any idea? I thought it should be possible.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 12:27 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
You can try a few things.

Look at the get, load, or refresh() methods of the session.

http://www.hibernate.org/hib_docs/v3/ap ... ssion.html

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

Budyanto


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 8:06 am 
Beginner
Beginner

Joined: Sat Feb 10, 2007 12:18 pm
Posts: 23
Thx. The load-method seems to be what I need but it gives me a strange result.

I have a Vehicle-Object with several Lists mapped as composite elements with lazy-loading = false.

When I call
Code:
vehicleObject = session.load(Vehicle.class, vehicleObject.getId());
the returned object only contains the id, all other attributes are empty and so are the lists?

I assumed that I get the complete Object from this method with all containing attributes.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 10:41 am 
Beginner
Beginner

Joined: Sat Feb 10, 2007 12:18 pm
Posts: 23
I have to correct myself. The Lists are not empty, they are of the type PersistentList which has something to do with lazy.loading, but as I mentioned before I've set all my mappings with lazy="false"?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 2:55 pm 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
session's clear method. If you are using any caching, evict method call of session helps.

_________________
Please rate if it helped


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.