@Override public Object getForInsert(Object owner, Map mergeMap, SharedSessionContractImplementor session) { if ( session == null ) { return UNKNOWN; } else { return session.getPersistenceContext().getOwnerId( entityName, propertyName, owner, mergeMap ); } }
/** * Get the current snapshot from the session */ @SuppressWarnings({"JavaDoc"}) protected final Serializable getSnapshot() { return session.getPersistenceContext().getSnapshot( this ); }
@Override public boolean isReadOnly() { return ( readOnly == null ? producer.getPersistenceContext().isDefaultReadOnly() : readOnly ); }
@Override public Object getForInsert(Object owner, Map mergeMap, SharedSessionContractImplementor session) { if ( session == null ) { return PropertyAccessStrategyBackRefImpl.UNKNOWN; } else { return session.getPersistenceContext().getIndexInOwner( entityName, propertyName, owner, mergeMap ); } }
protected boolean isConnectedToSession() { return session != null && session.isOpen() && session.getPersistenceContext().containsCollection( this ); }
@Override public boolean isNullifiable(boolean earlyInsert, SharedSessionContractImplementor session) { if ( getStatus() == Status.SAVING ) { return true; } else if ( earlyInsert ) { return !isExistsInDatabase(); } else { return session.getPersistenceContext().getNullifiableEntityKeys().contains( getEntityKey() ); } }
private void endCollectionLoad( final Object resultSetId, final SharedSessionContractImplementor session, final CollectionPersister collectionPersister) { //this is a query and we are loading multiple instances of the same collection role session.getPersistenceContext() .getLoadContexts() .getCollectionLoadContext( (ResultSet) resultSetId ) .endLoadingCollections( collectionPersister ); }
/** * Is this the "inverse" end of a bidirectional association? */ @SuppressWarnings({"JavaDoc"}) protected boolean isInverseCollection() { final CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( this ); return ce != null && ce.getLoadedPersister().isInverse(); }
@Override public boolean isReadOnly() { if ( ! isReadOnlyInitialized() && getSession() == null ) { throw new IllegalStateException( "cannot determine readOnly/modifiable setting when it is not initialized and is not initialized and getSession() == null" ); } return ( isReadOnlyInitialized() ? readOnly : getSession().getPersistenceContext().isDefaultReadOnly() ); }
/** * Is this the "inverse" end of a bidirectional association with * no orphan delete enabled? */ @SuppressWarnings({"JavaDoc"}) protected boolean isInverseCollectionNoOrphanDelete() { final CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( this ); return ce != null && ce.getLoadedPersister().isInverse() && !ce.getLoadedPersister().hasOrphanDelete(); }
public Object instantiate(Object parent, SharedSessionContractImplementor session) throws HibernateException { Object result = instantiate( entityMode ); if ( componentTuplizer.hasParentProperty() && parent != null ) { componentTuplizer.setParent( result, session.getPersistenceContext().proxyFor( parent ), session.getFactory() ); } return result; }
private SharedSessionContractImplementor openTemporarySessionForLoading() { if ( sessionFactoryUuid == null ) { throwLazyInitializationException( "SessionFactory UUID not known to create temporary Session for loading" ); } final SessionFactoryImplementor sf = (SessionFactoryImplementor) SessionFactoryRegistry.INSTANCE.getSessionFactory( sessionFactoryUuid ); final SharedSessionContractImplementor session = (SharedSessionContractImplementor) sf.openSession(); session.getPersistenceContext().setDefaultReadOnly( true ); session.setFlushMode( FlushMode.MANUAL ); return session; }
@Override public void endLoading(ResultSetProcessingContextImpl context) { context.getSession().getPersistenceContext() .getLoadContexts() .getCollectionLoadContext( context.getResultSet() ) .endLoadingCollections( collectionReference.getCollectionPersister() ); } }
@Override public boolean isNull(Object owner, SharedSessionContractImplementor session) { if ( propertyName != null ) { final EntityPersister ownerPersister = session.getFactory().getMetamodel().entityPersister( entityName ); final Serializable id = session.getContextEntityIdentifier( owner ); final EntityKey entityKey = session.generateEntityKey( id, ownerPersister ); return session.getPersistenceContext().isPropertyNull( entityKey, getPropertyName() ); } else { return false; } }
private SharedSessionContractImplementor openTemporarySessionForLoading(LazyInitializationWork lazyInitializationWork) { if ( consumer.getSessionFactoryUuid() == null ) { throwLazyInitializationException( Cause.NO_SF_UUID, lazyInitializationWork ); } final SessionFactoryImplementor sf = (SessionFactoryImplementor) SessionFactoryRegistry.INSTANCE.getSessionFactory( consumer.getSessionFactoryUuid() ); final SharedSessionContractImplementor session = (SharedSessionContractImplementor) sf.openSession(); session.getPersistenceContext().setDefaultReadOnly( true ); session.setHibernateFlushMode( FlushMode.MANUAL ); return session; } }
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { if ( !lockable.isVersioned() ) { throw new OptimisticLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } final EntityEntry entry = session.getPersistenceContext().getEntry( object ); // Register the EntityVerifyVersionProcess action to run just prior to transaction commit. ( (EventSource) session ).getActionQueue().registerProcess( new EntityVerifyVersionProcess( object, entry ) ); }
private void checkLockMode(Object entity, LockMode expectedLockMode, Session session) { final LockMode lockMode = ( (SharedSessionContractImplementor) session ).getPersistenceContext().getEntry( entity ).getLockMode(); assertEquals( expectedLockMode, lockMode ); }
/** * Is this the "inverse" end of a bidirectional one-to-many, or * of a collection with no orphan delete? */ @SuppressWarnings({"JavaDoc"}) protected boolean isInverseOneToManyOrNoOrphanDelete() { final CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( this ); return ce != null && ce.getLoadedPersister().isInverse() && ( ce.getLoadedPersister().isOneToMany() || !ce.getLoadedPersister().hasOrphanDelete() ); }
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } final EntityEntry entry = session.getPersistenceContext().getEntry( object ); // Register the EntityIncrementVersionProcess action to run just prior to transaction commit. ( (EventSource) session ).getActionQueue().registerProcess( new EntityIncrementVersionProcess( object, entry ) ); }
@Override public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) { if ( !lockable.isVersioned() ) { throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); } final EntityEntry entry = session.getPersistenceContext().getEntry( object ); final EntityPersister persister = entry.getPersister(); final Object nextVersion = persister.forceVersionIncrement( entry.getId(), entry.getVersion(), session ); entry.forceLocked( object, nextVersion ); }