-->
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: ConcurrentModificationException when cascading?
PostPosted: Mon Mar 07, 2005 6:46 am 
Newbie

Joined: Thu Mar 03, 2005 11:07 am
Posts: 6
Hibernate version:
2.1.7c

Mapping documents:

class A:

Code:
...
<set     name="myBs"
            lazy="true"
            inverse="true"
            cascade="delete"
            sort="unsorted"
            order-by="value"
        >

        <key    column="idA">
        </key>

        <one-to-many class="test.B"/>

</set>
...


class b:
Code:
...
<many-to-one
            name="myA"
            class="test.A"
            cascade="none"
            outer-join="true"
            update="true"
            insert="true"
            access="property"
        >
        <column name="idA"/>
</many-to-one>
...


Code between sessionFactory.openSession() and session.close():

Code:
session.delete(A);


In the Lifecylce delete method of class B (simplified):
Code:
getMyA.getMyBs.remove(this);


Full stack trace of any exception that occurs:

java.util.ConcurrentModificationException
....

Name and version of the database you are using:

MySQL 4.1.7

The generated SQL (show_sql=true):

-

Debug level Hibernate log excerpt:

-

Hello!

I have two classes A and B. A has a set of Bs (1:n) and the relationship is bidirectional. If A is deleted, all Bs should be deleted. I set the cascade to "delete" in class A. In class B I implemented the Lifecycle interface to update the java model when removing an instance of B (in this case, the set in class A must be updated).
When I delete an instance of B, everything is fine. However, I'm getting a ConcurrentModificationException when I delete an instance of A. Apparently I'm removing the instance of B from the set of A, while Hibernate is iterating this set. So how can I ensure a proper update of the java model? Must I do this outside of the Lifecycle methods?

Thanks!!
Jonas


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.