-->
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: Hibernate Session's persist and JPA's persist
PostPosted: Fri Feb 13, 2009 4:00 am 
Beginner
Beginner

Joined: Sat Feb 07, 2009 12:31 am
Posts: 21
Hi,

Could somebody please make some enlightenment to this confusing paragraph:

Quote:
Should I use persist() on the Session? The Hibernate Session interface also
features a persist() method. It has the same semantics as the persist()
operation of JPA. However, there’s an important difference between the
two operations with regard to flushing. During synchronization, a Hibernate
Session doesn’t cascade the persist() operation to associated entities
and collections, even if you mapped an association with this option.
It’s only cascaded to entities that are reachable when you call persist()!
Only save() (and update()) are cascaded at flush-time if you use the
Session API. In a JPA application, however, it’s the other way round:
Only persist() is cascaded at flush-time.


-- Java Persistence with Hibernate page 419

I don't understand the sentence in bold face, it seems to contradict its previous statement.

Does this mean hibernate session's persist() method cascades ONLY to reachable entities whereas JPA EntityManager's persist method cascades more further than just reachable entities?

And just what does "entities that are reachable" mean?

Thanks


Top
 Profile  
 
 Post subject: Re: Hibernate Session's persist and JPA's persist
PostPosted: Wed Sep 30, 2009 12:25 am 
Newbie

Joined: Wed Sep 30, 2009 12:00 am
Posts: 2
Hi,

I think that what you need to understand is "entities that are reachable". It means reachable in the Java sense: An object that is accessible from the object graphs starting from the objects in the stack of the thread. So if an object is reachable when you call Session.persist(), it is going to be persisted even if you remove it later after the call, but before the flush.

You have to search on the Java documentation what reachable means.

I hope it helps.


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.