private void throwLazyInitializationExceptionIfNotConnected() { if ( !isConnectedToSession() ) { throwLazyInitializationException("no session or session was closed"); } if ( !session.isConnected() ) { throwLazyInitializationException("session is disconnected"); } }
/** * To be called internally by the session, forcing * immediate initialization. */ public final void forceInitialization() throws HibernateException { if (!initialized) { if (initializing) { throw new AssertionFailure("force initialize loading collection"); } 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); } }
/** * To be called internally by the session, forcing * immediate initialization. */ public final void forceInitialization() throws HibernateException { if (!initialized) { if (initializing) { throw new AssertionFailure("force initialize loading collection"); } 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); } }
public final void initialize() throws HibernateException { if (target==null) { if ( session==null ) { throw new LazyInitializationException("could not initialize proxy - no Session"); } else if ( !session.isOpen() ) { throw new LazyInitializationException("could not initialize proxy - the owning Session was closed"); } else if ( !session.isConnected() ) { throw new LazyInitializationException("could not initialize proxy - the owning Session is disconnected"); } else { target = session.immediateLoad(entityName, id); } } }
private Object intercept(Object target, String fieldName, Object value) { if ( initializing ) return value; if ( uninitializedFields != null && uninitializedFields.contains( fieldName ) ) { if ( session == null ) { throw new LazyInitializationException( "entity with lazy properties is not associated with a session" ); } else if ( !session.isOpen() || !session.isConnected() ) { throw new LazyInitializationException( "session is not connected" ); } final Object result; initializing = true; try { result = ( ( LazyPropertyInitializer ) session.getFactory().getEntityPersister( entityName ) ) .initializeLazyProperty( fieldName, target, session ); } finally { initializing = false; } uninitializedFields = null; //let's assume that there is only one lazy fetch group, for now! return result; } else { return value; } }
protected final Object intercept(Object target, String fieldName, Object value) { if ( initializing ) { return value; } if ( uninitializedFields != null && uninitializedFields.contains( fieldName ) ) { if ( session == null ) { throw new LazyInitializationException( "entity with lazy properties is not associated with a session" ); } else if ( !session.isOpen() || !session.isConnected() ) { throw new LazyInitializationException( "session is not connected" ); } final Object result; initializing = true; try { result = ( ( LazyPropertyInitializer ) session.getFactory() .getEntityPersister( entityName ) ) .initializeLazyProperty( fieldName, target, session ); } finally { initializing = false; } uninitializedFields = null; //let's assume that there is only one lazy fetch group, for now! return result; } else { return value; } }
/** * Initialize the collection, if possible, wrapping any exceptions * in a runtime exception * @param writing currently obsolete * @throws LazyInitializationException if we cannot initialize */ protected final void initialize(boolean writing) { if (!initialized) { if (initializing) { throw new LazyInitializationException("illegal access to loading collection"); } if ( isConnectedToSession() ) { if ( session.isConnected() ) { session.initializeCollection(this, writing); } else { throwLazyInitializationException("session is disconnected"); } } else { throwLazyInitializationException("no session or session was closed"); } } }
public final void initialize() throws HibernateException { if (!initialized) { if ( session==null ) { throw new LazyInitializationException("could not initialize proxy - no Session"); } else if ( !session.isOpen() ) { throw new LazyInitializationException("could not initialize proxy - the owning Session was closed"); } else if ( !session.isConnected() ) { throw new LazyInitializationException("could not initialize proxy - the owning Session is disconnected"); } else { target = session.immediateLoad(entityName, id); initialized = true; checkTargetState(); } } else { checkTargetState(); } }