Java Code Examples for org.hibernate.engine.SessionImplementor#isOpen()

The following examples show how to use org.hibernate.engine.SessionImplementor#isOpen() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicLazyInitializer.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Object getReplacement() {

		final SessionImplementor session = getSession();
		if ( isUninitialized() && session != null && session.isOpen()) {
			final EntityKey key = new EntityKey(
					getIdentifier(),
			        session.getFactory().getEntityPersister( getEntityName() ),
			        session.getEntityMode()
				);
			final Object entity = session.getPersistenceContext().getEntity(key);
			if (entity!=null) setImplementation( entity );
		}

		if ( isUninitialized() ) {
			if (replacement==null) {
				replacement = serializableProxy();
			}
			return replacement;
		}
		else {
			return getTarget();
		}

	}
 
Example 2
Source File: PersistentOwnedSet.java    From webdsl with Apache License 2.0 5 votes vote down vote up
protected void throwLazyInitializationExceptionIfNotConnected() {
	SessionImplementor session = getSession();
	if ( !(session!=null && session.isOpen() && session.getPersistenceContext().containsCollection(this)) )  {
		throwLazyInitializationException("no session or session was closed");
	}
	if ( !session.isConnected() ) {
           throwLazyInitializationException("session is disconnected");
	}		
}
 
Example 3
Source File: PersistentOwnedList.java    From webdsl with Apache License 2.0 5 votes vote down vote up
protected void throwLazyInitializationExceptionIfNotConnected() {
	SessionImplementor session = getSession();
	if ( !(session!=null && session.isOpen() && session.getPersistenceContext().containsCollection(this)) )  {
		throwLazyInitializationException("no session or session was closed");
	}
	if ( !session.isConnected() ) {
           throwLazyInitializationException("session is disconnected");
	}		
}