-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with evict and cascading associations
PostPosted: Wed Nov 30, 2005 5:46 am 
Newbie

Joined: Wed Nov 02, 2005 4:03 am
Posts: 7
Hibernate version: 3 / JBoss 4.0.3 SP 1

Hello,

I've got a problem with evict together with cascading associations.

For example given the following model:

Class Person has association "memberOf" to class department.

Class Person has another association "proxies" to class Person.

Association "memberOf" is CascadeType=ALL.

Person p1 is memberOf Department d1.
Person p2 is memberOf the same Department.

p2 is proxy of p1.

The following code:

session.update(p1);
Hibernate.initialize(p1.getProxies());
session.evict(p1);

is used to initialize the proxy collection of p1, containing one element p2.

At end of transaction, there is an error because of an update to an object which is not in the first level cache. After some debugging I found the reason:

Evicting p1 also evicts d1 (because of cascade).
Evicting p1 does not evict p2 (because of no cascade). p2 is updated.
But: updating p2 also updates d1 (because of cascade).
d1 is already evicted. Error!

Is there something wrong with my model? What can I do to repair this?

Marcus.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.