• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic