public void postInitialize(PersistentCollection collection) throws HibernateException { snapshot = getLoadedPersister().isMutable() ? collection.getSnapshot( getLoadedPersister() ) : null; collection.setSnapshot(loadedKey, role, snapshot); if ( getLoadedPersister().getBatchSize() > 1 ) { ( (AbstractPersistentCollection) collection ).getSession() .getPersistenceContext() .getBatchFetchQueue() .removeBatchLoadableCollection( this ); } }
assertSame( s, maniesEEOneStateOrig.getSession() ); assertNull( maniesEEOneStateOrig.getSession() ); s.getTransaction().commit(); s.close();
assertSame( s, maniesEEOneStateOrig.getSession() ); assertNull( maniesEEOneStateOrig.getSession() );
assertSame( s, maniesEEOneStateOrig.getSession() ); assertNull( maniesEEOneStateOrig.getSession() ); s.getTransaction().commit(); s.close();
assertSame( s, maniesEEOneStateOrig.getSession() ); assertNull( maniesEEOneStateOrig.getSession() ); s.getTransaction().commit(); s.close();
assertSame( s, maniesEEOneStateOrig.getSession() ); assertNull( maniesEEOneStateOrig.getSession() );
assertSame( s, maniesEEOneStateOrig.getSession() ); assertNull( maniesEEOneStateOrig.getSession() );
assertSame( s, maniesEEOneStateOrig.getSession() ); assertEquals( role, ( (PersistentCollection) one.getManies() ).getRole() ); assertEquals( one.getId(), ( (PersistentCollection) one.getManies() ).getKey() ); assertSame( s, ( (AbstractPersistentCollection) one.getManies() ).getSession() ); assertNull( maniesEEOneStateOrig.getSession() );
assertSame( s, maniesEEOneStateOrig.getSession() ); assertEquals( role, ( (PersistentCollection) one.getManies() ).getRole() ); assertEquals( one.getId(), ( (PersistentCollection) one.getManies() ).getKey() ); assertSame( s, ( (AbstractPersistentCollection) one.getManies() ).getSession() ); assertNull( maniesEEOneStateOrig.getSession() );
assertSame( s, maniesEEOneStateOrig.getSession() ); assertEquals( role, ( (PersistentCollection) one.getManies() ).getRole() ); assertEquals( one.getId(), ( (PersistentCollection) one.getManies() ).getKey() ); assertSame( s, ( (AbstractPersistentCollection) one.getManies() ).getSession() ); assertNull( maniesEEOneStateOrig.getSession() );
/** * Whenever the entity has dirty persistent collection, make them clean to * workaround a "bug" with hibernate since hibernate cannot re-attach a * "dirty" detached collection. * * @param collection the collection * @param targetSession the session that is targeted to after the dirty states have been * reset or null if none. */ public static void unsetCollectionHibernateSession(PersistentCollection collection, Session targetSession) { // Whenever the entity has dirty persistent collection, make them // clean to workaround a "bug" with hibernate since hibernate cannot // re-attach a "dirty" detached collection. if (collection != null) { if (Hibernate.isInitialized(collection)) { collection.clearDirty(); } if (collection instanceof AbstractPersistentCollection && ((AbstractPersistentCollection) collection).getSession() != null && targetSession != ((AbstractPersistentCollection) collection).getSession()) { // The following is to avoid to avoid Hibernate exceptions due to // re-associating a collection that is already associated with the // session. collection.unsetSession(((AbstractPersistentCollection) collection).getSession()); } } }
protected static boolean isConnectedToSession(AbstractPersistentCollection c) { SessionImplementor session = c.getSession(); return session!=null && session.isOpen() && session.getPersistenceContext().containsCollection(c); }
protected static void throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection c) { if (!isConnectedToSession(c)) { throwLazyInitializationException(c, "no session or session was closed"); } if (!c.getSession().isConnected()) { throwLazyInitializationException(c, "session is disconnected"); } }
if (apc.getSession() == null) { try { apc.setCurrentSession((SessionImplementor) hibernateSession);
public void postInitialize(PersistentCollection collection) throws HibernateException { snapshot = getLoadedCollectionDescriptor().getMutabilityPlan().isMutable() ? collection.getSnapshot( getLoadedCollectionDescriptor() ) : null; collection.setSnapshot(loadedKey, role, snapshot); if ( getLoadedCollectionDescriptor().getBatchSize() > 1 ) { ( (AbstractPersistentCollection) collection ).getSession() .getPersistenceContext() .getBatchFetchQueue() .removeBatchLoadableCollection( this ); } }
if (((AbstractPersistentCollection) propertyValue).getSession() != null && ((AbstractPersistentCollection) propertyValue).getSession().isOpen()) { try { Hibernate.initialize(propertyValue);