File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Complete Example Reproducing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Complete Example Reproducing "Found shared references to a collection"?" Watch "Complete Example Reproducing "Found shared references to a collection"?" New topic
Author

Complete Example Reproducing "Found shared references to a collection"?

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Is there any complete (small) example showing how to reproduce the "found shared references to a collection" with JPA2 and Hibernate?
I have tried the example here: https://forum.hibernate.org/viewtopic.php?p=2273553
However, without luck (or errors).
Is this problem something that has been addressed in a later version (3.6) of Hibernate?
Thanks in advance!


My free books and tutorials: http://www.slideshare.net/krizsan
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
A couple of notes, in case someone else stumbles upon this:
The problem is that Hibernate supplies implementation of the collection interfaces, for instance Set.
You cannot set a collection of entity A to a collection instance that belongs to another entity.
Assume that you have a one-to-many relation from entities A and B to some kind items. If you try to move the items from a collection in entity A to a collection in entity B, you will have to remove the items from the collection of entity A before adding them to the collection of entity B. The order of these operations is significant. If the association is many-to-many, this will not be a problem.
I finally managed to write a small example program reproducing the problem and can post it upon request.
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Complete Example Reproducing "Found shared references to a collection"?
 
Similar Threads
What is shared references in hibernate
Is Kathy&Bert book wrong? Or my understanding wrong?
History of object in Hibernate
Collection of components
Hibernate: Found Shared References to a Collection