Hallo,
I am currently examinig the xml persistence capabilities of Hibernate 3.
In my class, I have 2 sets containing other (entity) classes.
Consider the following:
Code:
class MyClass {
Set set1;
Set set2;
//appropriate getters and setters
}
Mapping:
Code:
...
<set name="set1" table="set1_table" node="." embed-xml="true">
<key column="parent_id" not-null="true"/>
<one-to-many class="Set1Class" node="set1-class"/>
</set>
...
So if I map only one set, everything id fine. The set elements are created as direct children of the element of the class.
Now, if do the same thing with the other set, I get an
org.hibernate.HibernateException with the message
Found shared references to a collection.
Nevertheless the xml document is created correctly!
So if I don't use the "." value for the node but two custom elements which encapsulate elements from set1 and set2, no error is produced.
So isn't it possible to have elements of several collections as children of one class-wide element? If not, why (and if it is, how)?
Thanks in advance.
Hibernate version: 3.0.5
Full stack trace of any exception that occurs:
Found shared references to a collection
at org.hibernate.engine.Collections.processReachableCollection(Collections.java:130)
at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:198)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:329)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at de.bebit.blackbook.util.HibernateUtil.commitTransaction(HibernateUtil.java:119)
at de.bebit.blackbook.test.Test.main(Test.java:94)
Name and version of the database you are using: Mysql 4