public TransactionCompletionProcesses getTransactionCompletionProcesses() { if( beforeTransactionProcesses == null ) { beforeTransactionProcesses = new BeforeTransactionCompletionProcessQueue( session ); } if( afterTransactionProcesses == null ) { afterTransactionProcesses = new AfterTransactionCompletionProcessQueue( session ); } return new TransactionCompletionProcesses( beforeTransactionProcesses, afterTransactionProcesses ); }
private static EntityKey generateEntityKeyOrNull(Serializable id, SharedSessionContractImplementor s, String entityName) { if ( id == null || s == null || entityName == null ) { return null; } return s.generateEntityKey( id, s.getFactory().getEntityPersister( entityName ) ); }
/** * Get the current snapshot from the session */ @SuppressWarnings({"JavaDoc"}) protected final Serializable getSnapshot() { return session.getPersistenceContext().getSnapshot( this ); }
/** * entity id accessor * * @return The entity id */ public final Serializable getId() { if ( id instanceof DelayedPostInsertIdentifier ) { final EntityEntry entry = session.getPersistenceContext().getEntry( instance ); final Serializable eeId = entry == null ? null : entry.getId(); return eeId instanceof DelayedPostInsertIdentifier ? null : eeId; } return id; }
private void checkLockMode(Object entity, LockMode expectedLockMode, Session session) { final LockMode lockMode = ( (SharedSessionContractImplementor) session ).getPersistenceContext().getEntry( entity ).getLockMode(); assertEquals( expectedLockMode, lockMode ); }
protected boolean isConnectedToSession() { return session != null && session.isOpen() && session.getPersistenceContext().containsCollection( this ); }
/** * Down-grade locks to NONE for all entities in this context */ public void downgradeLocks() { if ( head == null ) { return; } ManagedEntity node = head; while ( node != null ) { node.$$_hibernate_getEntityEntry().setLockMode( LockMode.NONE ); node = node.$$_hibernate_getNextManagedEntity(); } }
protected SessionBuilder newSession(String tenant) { return sessionFactory .withOptions() .tenantIdentifier( tenant ); }
@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 ); } }
@Override public Object getForInsert(Object owner, Map mergeMap, SharedSessionContractImplementor session) { if ( session == null ) { return UNKNOWN; } else { return session.getPersistenceContext().getOwnerId( entityName, propertyName, owner, mergeMap ); } }
public boolean hasAnyQueuedActions() { return ( updates != null && !updates.isEmpty() ) || ( insertions != null && !insertions.isEmpty() ) || hasUnresolvedEntityInsertActions() || ( deletions != null && !deletions.isEmpty()) || ( collectionUpdates != null && !collectionUpdates.isEmpty() ) || ( collectionQueuedOps != null && !collectionQueuedOps.isEmpty() ) || ( collectionRemovals != null && !collectionRemovals.isEmpty() ) || ( collectionCreations != null && !collectionCreations.isEmpty() ); }
public FetchGraphLoadPlanBuildingStrategy( final SessionFactoryImplementor sessionFactory, RootGraphImplementor graph, final LoadQueryInfluencers loadQueryInfluencers, final LockMode lockMode) { super( sessionFactory, loadQueryInfluencers, lockMode ); this.rootEntityGraph = graph; }
/** * Perform all currently queued entity-insertion actions. * * @throws HibernateException error executing queued insertion actions. */ public void executeInserts() throws HibernateException { if ( insertions != null && !insertions.isEmpty() ) { executeActions( insertions ); } }
public void sortActions() { if ( isOrderUpdatesEnabled() && updates != null ) { // sort the updates by pk updates.sort(); } if ( isOrderInsertsEnabled() && insertions != null ) { insertions.sort(); } }
@Override public void jdbcExecuteStatementStart() { session.getEventListenerManager().jdbcExecuteStatementStart(); }
@Override public void jdbcExecuteBatchEnd() { session.getEventListenerManager().jdbcExecuteBatchEnd(); }
/** * Check whether any insertion or deletion actions are currently queued. * * @return {@code true} if insertions or deletions are currently queued; {@code false} otherwise. */ public boolean areInsertionsOrDeletionsQueued() { return ( insertions != null && !insertions.isEmpty() ) || hasUnresolvedEntityInsertActions() || (deletions != null && !deletions.isEmpty()) || (orphanRemovals != null && !orphanRemovals.isEmpty()); }
public LoadGraphLoadPlanBuildingStrategy( SessionFactoryImplementor factory, RootGraphImplementor<?> graph, LoadQueryInfluencers queryInfluencers, LockMode lockMode) { super( factory, queryInfluencers, lockMode ); this.rootEntityGraph = graph; }