-->
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: Cascade saving Tree likes structure
PostPosted: Wed Aug 04, 2004 8:53 am 
For some reason registration process is very dificult and I have to wait some time to use my account and I couldn't finish one. So I'm asking about my problem from this login.

I want to save Tree like structire with Hibernate 2.1.4 and see next exception:
[code]
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:448)
at java.util.AbstractList$Itr.next(AbstractList.java:419)
at net.sf.hibernate.collection.PersistentCollection$IteratorProxy.next(PersistentCollection.java:437)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:951)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:779)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
[/code]

I have next class that I want to save:
[code]
package hibertest;

import java.util.List;
import java.util.ArrayList;

public class TestObj {
private String id;
private String name;
private List children = new ArrayList(0);

public TestObj() {

}

public TestObj(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

private TestObj parent;

public TestObj getParent() {
return parent;
}

public void setParent(TestObj parent) {
this.parent = parent;
if (parent != null)
parent.children.add(this);
}

public List getChildren() {
return children;
}

public void setChildren(List children) {
this.children = children;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}
}
[/code]

and next Hibernate mapping file:
[code]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="hibertest">
<class name="TestObj" table="test">
<id name="id" column="pk" type="string" >
<generator class="uuid.hex"/>
</id>
<property name="name" column="name" type="string" not-null="true"/>


<many-to-one name="parent" cascade="all">
<column name="parent" index="pind"/>
</many-to-one>

<bag name="children" inverse="true" cascade="all">
<key column="parent"/>
<one-to-many class="TestObj"/>
</bag>
</class>

</hibernate-mapping>
[/code]

If I remove [i]cascading[/i] attribute from [i]bag[/i] XML tag. It's work but I have to save each element that not possible for my.

Can somebody help me with my problem?


Top
  
 
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.