Methods Summary |
---|
private void | checkTargetState()
if ( !unwrap ) {
if ( target == null ) {
getSession().getFactory().getEntityNotFoundDelegate().handleEntityNotFound( entityName, id );
}
}
|
public final java.lang.String | getEntityName()
return entityName;
|
public final java.io.Serializable | getIdentifier()
return id;
|
public final java.lang.Object | getImplementation()Return the underlying persistent object, initializing if necessary
initialize();
return target;
|
public final java.lang.Object | getImplementation(org.hibernate.engine.SessionImplementor s)Return the underlying persistent object in the given Session, or null,
do not initialize the proxy
final EntityKey entityKey = new EntityKey(
getIdentifier(),
s.getFactory().getEntityPersister( getEntityName() ),
s.getEntityMode()
);
return s.getPersistenceContext().getEntity( entityKey );
|
public final org.hibernate.engine.SessionImplementor | getSession()
return session;
|
protected final java.lang.Object | getTarget()
return target;
|
public final void | initialize()
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();
}
|
protected final boolean | isConnectedToSession()
return session!=null &&
session.isOpen() &&
session.getPersistenceContext().containsProxy(this);
|
public final boolean | isUninitialized()
return !initialized;
|
public boolean | isUnwrap()
return unwrap;
|
public final void | setIdentifier(java.io.Serializable id)
this.id = id;
|
public final void | setImplementation(java.lang.Object target)
this.target = target;
initialized = true;
|
public final void | setSession(org.hibernate.engine.SessionImplementor s)
if (s!=session) {
if ( isConnectedToSession() ) {
//TODO: perhaps this should be some other RuntimeException...
throw new HibernateException("illegally attempted to associate a proxy with two open Sessions");
}
else {
session = s;
}
}
|
public void | setUnwrap(boolean unwrap)
this.unwrap = unwrap;
|