-->
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: Cascade Persist
PostPosted: Fri Aug 17, 2007 5:10 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hibernate version:
Annotations: Version: 3.2.0 CR1
Core: version 3.2 cr2
EntityManager: Version: 3.2.0.CR1

Hi,
I have Cascade Persist set on both sides of a relationship between Person and Address.
I create a relationship between a persistent Person which is attached and a transient Address which is not attached. The Address is inserted in the Database and the relationship is created.

Code:
person.setHomeAddress(address);
System.out.println("em.contains(address)" + em.contains(address));
em.getTransaction().begin();
em.getTransaction().commit();
System.out.println("em.contains(address)" + em.contains(address));


Before the commit, the person is attached and the address is detached. During the commit, the address is persisted. After the commit the address is attached.

This is confusing me because a persist is cascaded to the Address even though I never invoke persist on the address.

When I remove the cascade persist option, the address is not persisted.

Can someone explain how persist is cascaded in situations where persist() is not explictly called?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 24, 2007 10:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is as per the spec, PERSIST is the cascaded operation on FLUSH.

_________________
Emmanuel


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.