BasicLazyInitializerpublic abstract class BasicLazyInitializer extends org.hibernate.proxy.AbstractLazyInitializer Lazy initializer for POJOs |
Fields Summary |
---|
protected static final Object | INVOKE_IMPLEMENTATION | protected Class | persistentClass | protected Method | getIdentifierMethod | protected Method | setIdentifierMethod | protected boolean | overridesEquals | private Object | replacement | protected org.hibernate.type.AbstractComponentType | componentIdType |
Methods Summary |
---|
public final java.lang.Class | getPersistentClass()
return persistentClass;
| private java.lang.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 final java.lang.Object | invoke(java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object proxy)
String methodName = method.getName();
int params = args.length;
if ( params==0 ) {
if ( "writeReplace".equals(methodName) ) {
return getReplacement();
}
else if ( !overridesEquals && "hashCode".equals(methodName) ) {
return new Integer( System.identityHashCode(proxy) );
}
else if ( isUninitialized() && method.equals(getIdentifierMethod) ) {
return getIdentifier();
}
else if ( "getHibernateLazyInitializer".equals(methodName) ) {
return this;
}
}
else if ( params==1 ) {
if ( !overridesEquals && "equals".equals(methodName) ) {
return args[0]==proxy ? Boolean.TRUE : Boolean.FALSE;
}
else if ( method.equals(setIdentifierMethod) ) {
initialize();
setIdentifier( (Serializable) args[0] );
return INVOKE_IMPLEMENTATION;
}
}
//if it is a property of an embedded component, invoke on the "identifier"
if ( componentIdType!=null && componentIdType.isMethodOf(method) ) {
return method.invoke( getIdentifier(), args );
}
// otherwise:
return INVOKE_IMPLEMENTATION;
| protected abstract java.lang.Object | serializableProxy()
|
|