This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Complete Example Reproducing "Found shared references to a collection"?
 
Similar Threads
Collection of components
Hibernate: Found Shared References to a Collection
Is Kathy&Bert book wrong? Or my understanding wrong?
History of object in Hibernate
What is shared references in hibernate