Revert "HHH-10608 - Avoid exception from Hibernate.initialize when lazy_no_transaction is enabled"

This reverts commit d79305164b.
This commit is contained in:
Gail Badner 2016-03-14 15:53:41 -07:00
parent 4c82bba071
commit 91bcc843e3
2 changed files with 7 additions and 17 deletions

View File

@ -736,7 +736,13 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
if ( initializing ) {
throw new AssertionFailure( "force initialize loading collection" );
}
initialize( false );
if ( session == null ) {
throw new HibernateException( "collection is not associated with any session" );
}
if ( !session.isConnected() ) {
throw new HibernateException( "disconnected session" );
}
session.initializeCollection( this, false );
}
}

View File

@ -21,7 +21,6 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
@ -54,21 +53,6 @@ public class CacheLazyLoadNoTransTest extends BaseNonConfigCoreFunctionalTestCas
settings.put( Environment.CACHE_PROVIDER_CONFIG, "true" );
}
@Test
public void hibernateInitialize() {
Customer customer = new Customer();
Item item1 = new Item( customer );
Item item2 = new Item( customer );
customer.boughtItems.add( item1 );
customer.boughtItems.add( item2 );
persist( customer );
customer = find( Customer.class, customer.id );
assertFalse( Hibernate.isInitialized( customer.boughtItems ) );
Hibernate.initialize( customer.boughtItems );
assertTrue( Hibernate.isInitialized( customer.boughtItems ) );
}
@Test
public void testOneToMany() {
Customer customer = new Customer();