下面列出了org.hibernate.engine.SessionImplementor#isOpen ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
}
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");
}
}
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");
}
}