-->
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.  [ 3 posts ] 
Author Message
 Post subject: pre hibernate user question about detach/attach
PostPosted: Thu Nov 11, 2004 3:32 pm 
Newbie

Joined: Mon Mar 08, 2004 6:45 pm
Posts: 6
We are currently using an implementation of JDO. One of the really annoying things about it is that you always need to have a peristence manager when working with a persisted object.

What we really want is to retrieve the object, close the transaction, and go merrily about our business. Later when the object has changed, we want to be able to persiste those changes. We do this because we send these objects to other process via RMI, JMS, etc.

To accomplish this in JDO, we will need to we have to make a call to detach; functionality that we will need to pay for (another mickey mouse charge).

I looked through the forums and it appears that this is not true for Hibernate. All that is needed to be done is to retrieve the object and then close the session. Is this correct?

If I could get as much detail as possible that would be great. I want to fully understand this before I recommend to switch to Hibernate to my lead.

A link to a page in the manual would be welcomed as well. In the mean time, I will keep looking.

Thank you.
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 6:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Hibernate introduced this functionality quite some time ago. There is not a lot to read since an object become transient as soon as its not involved in a session. The introduce the object back into a session you just update the object (or lock)., eg, here is some psudo code [simplistic but you will get the idea].

// Open a session then get the object
Session sess = sfactory.getSession();
DObject do = sess.load(DObject.class, ID);
sfactory.endSession();

// No active session but object can be manipulated.
// This could have been sent to web tier and stored in http session etc
do.setProperty(something);

// Start another session to persist the changes
Session sess = sfactory.getSession();
sess.update(do);
sfactory.endSession();

Thats it.
Obviosuly this is an outline the session needs transactions etc.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 26, 2004 1:36 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
Definitely do proof of concept before committing to anything. I migrated to Hibernate from OJB (and though I would have migrated anyway since Hibernate is much better), some things didnt work as I had thought after reading docs. Here is an example: if you have an object, and it has a Set inside, with a 1-to-many, and you do not have the exact same Set instance (i.e. if you serialize over RMI), then it will not save back to the database in the same way as it would if you didnt serialize (e.g. dirty checking is out the window)... Anyways, Hibernate is good, you should consider moving to it, but do proof of concepts to see for yourself. Chris


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