@Override public final Object getImplementation(SharedSessionContractImplementor s) throws HibernateException { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), s, getEntityName() ); return (entityKey == null ? null : s.getPersistenceContext().getEntity( entityKey )); }
private Object getProxyOrNull() { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( entityKey != null && session != null && session.isOpenOrWaitingForAutoClose() ) { return session.getPersistenceContext().getProxy( entityKey ); } return null; }
@Override public final void setReadOnly(boolean readOnly) { errorIfReadOnlySettingNotAvailable(); // only update if readOnly is different from current setting if ( this.readOnly != readOnly ) { final EntityPersister persister = session.getFactory().getEntityPersister( entityName ); if ( !persister.isMutable() && !readOnly ) { throw new IllegalStateException( "cannot make proxies [" + entityName + "#" + id + "] for immutable entities modifiable" ); } this.readOnly = readOnly; if ( initialized ) { EntityKey key = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( key != null && session.getPersistenceContext().containsEntity( key ) ) { session.getPersistenceContext().setReadOnly( target, readOnly ); } } } }
/** * Attempt to initialize the proxy without loading anything from the database. * * This will only have any effect if the proxy is still attached to a session, * and the entity being proxied has been loaded and added to the persistence context * of that session since the proxy was created. */ public final void initializeWithoutLoadIfPossible() { if ( !initialized && session != null && session.isOpenOrWaitingForAutoClose() ) { final EntityKey key = session.generateEntityKey( getIdentifier(), session.getFactory().getMetamodel().entityPersister( getEntityName() ) ); final Object entity = session.getPersistenceContext().getEntity( key ); if ( entity != null ) { setImplementation( entity ); } } }
@Override public final Object getImplementation(SessionImplementor s) throws HibernateException { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), s, getEntityName() ); return ( entityKey == null ? null : s.getPersistenceContext().getEntity( entityKey ) ); }
@Override public final Object getImplementation(SessionImplementor s) throws HibernateException { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), s, getEntityName() ); return ( entityKey == null ? null : s.getPersistenceContext().getEntity( entityKey ) ); }
@Override public final Object getImplementation(SharedSessionContractImplementor s) throws HibernateException { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), s, getEntityName() ); return (entityKey == null ? null : s.getPersistenceContext().getEntity( entityKey )); }
private Object getProxyOrNull() { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( entityKey != null && session != null && session.isOpen() ) { return session.getPersistenceContext().getProxy( entityKey ); } return null; }
private Object getProxyOrNull() { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( entityKey != null && session != null && session.isOpen() ) { return session.getPersistenceContext().getProxy( entityKey ); } return null; }
private Object getProxyOrNull() { final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( entityKey != null && session != null && session.isOpen() ) { return session.getPersistenceContext().getProxy( entityKey ); } return null; }
/** * Return the underlying persistent object in the given <tt>Session</tt>, or null, * do not initialize the proxy */ public final Object getImplementation(SessionImplementor s) throws HibernateException { return s.getPersistenceContext().getEntity( new EntityKey( getIdentifier(), s.getFactory().getEntityPersister( getEntityName() ), s.getEntityMode() ) ); }
/** * Return the underlying persistent object in the given <tt>Session</tt>, or null, * do not initialize the proxy */ public final Object getImplementation(SessionImplementor s) throws HibernateException { final EntityKey entityKey = new EntityKey( getIdentifier(), s.getFactory().getEntityPersister( getEntityName() ), s.getEntityMode() ); return s.getPersistenceContext().getEntity( entityKey ); }
@Override public final void setReadOnly(boolean readOnly) { errorIfReadOnlySettingNotAvailable(); // only update if readOnly is different from current setting if ( this.readOnly != readOnly ) { final EntityPersister persister = session.getFactory().getEntityPersister( entityName ); if ( ! persister.isMutable() && ! readOnly ) { throw new IllegalStateException( "cannot make proxies for immutable entities modifiable"); } this.readOnly = readOnly; if ( initialized ) { EntityKey key = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( key != null && session.getPersistenceContext().containsEntity( key ) ) { session.getPersistenceContext().setReadOnly( target, readOnly ); } } } }
@Override public final void setReadOnly(boolean readOnly) { errorIfReadOnlySettingNotAvailable(); // only update if readOnly is different from current setting if ( this.readOnly != readOnly ) { final EntityPersister persister = session.getFactory().getEntityPersister( entityName ); if ( ! persister.isMutable() && ! readOnly ) { throw new IllegalStateException( "cannot make proxies for immutable entities modifiable"); } this.readOnly = readOnly; if ( initialized ) { EntityKey key = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( key != null && session.getPersistenceContext().containsEntity( key ) ) { session.getPersistenceContext().setReadOnly( target, readOnly ); } } } }
@Override public final void setReadOnly(boolean readOnly) { errorIfReadOnlySettingNotAvailable(); // only update if readOnly is different from current setting if ( this.readOnly != readOnly ) { final EntityTypeDescriptor entityDescriptor = session.getFactory().getEntityPersister( entityName ); if ( !entityDescriptor.getJavaTypeDescriptor().getMutabilityPlan().isMutable() && !readOnly ) { throw new IllegalStateException( "cannot make proxies [" + entityName + "#" + id + "] for immutable entities modifiable" ); } this.readOnly = readOnly; if ( initialized ) { EntityKey key = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() ); if ( key != null && session.getPersistenceContext().containsEntity( key ) ) { session.getPersistenceContext().setReadOnly( target, readOnly ); } } } }
/** * Attempt to initialize the proxy without loading anything from the database. * * This will only have any effect if the proxy is still attached to a session, * and the entity being proxied has been loaded and added to the persistence context * of that session since the proxy was created. */ public final void initializeWithoutLoadIfPossible() { if ( !initialized && session != null && session.isOpen() ) { final EntityKey key = session.generateEntityKey( getIdentifier(), session.getFactory().getMetamodel().entity( getEntityName() ) ); final Object entity = session.getPersistenceContext().getEntity( key ); if ( entity != null ) { setImplementation( entity ); } } }