-->
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: Parent/Child relationship delete with cached children
PostPosted: Tue Mar 10, 2009 6:12 am 
Newbie

Joined: Wed Apr 23, 2008 11:11 pm
Posts: 19
I have the following entity


Code:
class Parent {


    @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
    @Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE,
                 region = "com.foo.DefaultCollectionCache")   
    protected Set<ChildrenEntity> children =
          new HashSet<ChildrenEntity>();

}


The cached collection was not activated previously and everything runs fine. Since we activated collection cache we have failure in our unit test in the tearDown.

We have a unit test that creates a Parent (A) then create a child (B) and associated B to A (setParent(A))

In the teardown we remove first B then we try to remove A. With caching activated, we get

Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.foo.ChildrenEntity#8aacfe031fefbbde011fefd365d20068]


I suppose that Hibernate is trying to remove the orphean but a legitimate call to remove was done just before and it's working fine without the cache.

Any idea?


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.