Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. /**
  2. * Initialize the role of the collection.
  3. *
  4. * The CollectionEntry.reached stuff is just to detect any silly users who set up
  5. * circular or shared references between/to collections.
  6. */
  7. void updateReachableCollection(PersistentCollection coll, Type type, Object owner) throws HibernateException {
  8.  
  9. CollectionEntry ce = getCollectionEntry(coll);
  10.  
  11. if (ce==null) {
  12. // refer to comment in addCollection()
  13. 0x throw new HibernateException("Found two representations of same collection: " + coll.getCollectionSnapshot().getRole());
  14. }
  15.  
  16. if (ce.reached) {
  17. // We've been here before
  18. 0x throw new HibernateException("Found shared references to a collection: " + coll.getCollectionSnapshot().getRole());
  19. }
  20. ce.reached = true;
  21.  
  22. CollectionPersister persister = getCollectionPersister( ( (PersistentCollectionType) type ).getRole() );
  23. ce.currentPersister = persister;
  24. ce.currentKey = getEntityIdentifier(owner); //TODO: better to pass the id in as an argument?
  25.  
  26. if ( log.isDebugEnabled() ) {
  27. log.debug(
  28. "Collection found: " + MessageHelper.infoString(persister, ce.currentKey) +
  29. ", was: " + MessageHelper.infoString(ce.loadedPersister, ce.loadedKey)
  30. );
  31. }
  32.  
  33. prepareCollectionForUpdate(coll, ce);
  34.  
  35. }
Add Comment
Please, Sign In to add comment