protected void specialSpecjInitialization() {
if ( session == null ) {
//we have a detached collection thats set to null, reattach
if ( sessionFactoryUuid == null ) {
throw new LazyInitializationException( "could not initialize proxy - no Session" );
}
try {
SessionFactoryImplementor sf = (SessionFactoryImplementor)
SessionFactoryRegistry.INSTANCE.getSessionFactory( sessionFactoryUuid );
SessionImplementor session = (SessionImplementor) sf.openSession();
try {
target = session.immediateLoad( entityName, id );
}
finally {
// make sure the just opened temp session gets closed!
try {
( (Session) session ).close();
}
catch (Exception e) {
log.warn( "Unable to close temporary session used to load lazy proxy associated to no session" );
}
}
initialized = true;
checkTargetState();
}
catch (Exception e) {
e.printStackTrace();
throw new LazyInitializationException( e.getMessage() );
}
}
else if ( session.isOpen() && session.isConnected() ) {
target = session.immediateLoad( entityName, id );
initialized = true;
checkTargetState();
}
else {
throw new LazyInitializationException( "could not initialize proxy - Session was closed or disced" );
}
}