-->
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: XML: Shared resources when using two nodes width ".&quo
PostPosted: Thu Jul 28, 2005 4:53 am 
Newbie

Joined: Tue Jul 26, 2005 6:26 am
Posts: 15
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


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.