/** * Register the entity as batch loadable, if enabled */ @SuppressWarnings({ "JavaDoc" }) private void scheduleBatchLoadIfNeeded(Serializable id, SharedSessionContractImplementor session) throws MappingException { //cannot batch fetch by unique key (property-ref associations) if ( uniqueKeyPropertyName == null && id != null ) { final EntityPersister persister = getAssociatedEntityPersister( session.getFactory() ); if ( persister.isBatchLoadable() ) { final EntityKey entityKey = session.generateEntityKey( id, persister ); if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } } }
persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); persistenceContext.addProxy( keyToLoad, proxy ); return proxy;
/** * Register the entity as batch loadable, if enabled */ @SuppressWarnings({ "JavaDoc" }) private void scheduleBatchLoadIfNeeded(Serializable id, SessionImplementor session) throws MappingException { //cannot batch fetch by unique key (property-ref associations) if ( uniqueKeyPropertyName == null && id != null ) { final EntityPersister persister = session.getFactory().getEntityPersister( getAssociatedEntityName() ); final EntityKey entityKey = session.generateEntityKey( id, persister ); if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } }
/** * Register the entity as batch loadable, if enabled */ @SuppressWarnings({ "JavaDoc" }) private void scheduleBatchLoadIfNeeded(Serializable id, SessionImplementor session) throws MappingException { //cannot batch fetch by unique key (property-ref associations) if ( uniqueKeyPropertyName == null && id != null ) { final EntityPersister persister = session.getFactory().getEntityPersister( getAssociatedEntityName() ); final EntityKey entityKey = session.generateEntityKey( id, persister ); if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } }
/** * Register the entity as batch loadable, if enabled * * Copied from {@link org.hibernate.type.ManyToOneType#scheduleBatchLoadIfNeeded} */ private void scheduleBatchLoadIfNeeded(Serializable id, SharedSessionContractImplementor session) throws MappingException { //cannot batch fetch by unique key (property-ref associations) if ( StringHelper.isEmpty( delegate.getRHSUniqueKeyPropertyName() ) && id != null ) { EntityPersister persister = session.getFactory().getMetamodel().entityPersister( delegate.getAssociatedEntityName() ); EntityKey entityKey = session.generateEntityKey( id, persister ); if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } }
persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); persistenceContext.addProxy( keyToLoad, proxy ); return proxy;
persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); persistenceContext.addProxy( keyToLoad, proxy ); return proxy;
@SuppressWarnings("WeakerAccess") protected void resolveEntityKey(RowProcessingState rowProcessingState) { if ( entityKey != null ) { // its already been resolved return; } final SharedSessionContractImplementor session = rowProcessingState.getJdbcValuesSourceProcessingState().getSession(); // 1) resolve the hydrated identifier value(s) into its identifier representation final Object id = identifierAssembler.assemble( rowProcessingState, rowProcessingState.getJdbcValuesSourceProcessingState().getProcessingOptions() ); if ( id == null ) { missing = true; // EARLY EXIT!!! return; } // 2) build the EntityKey this.entityKey = new EntityKey( id, concreteDescriptor.getEntityDescriptor() ); // 3) schedule the EntityKey for batch loading, if possible if ( concreteDescriptor.getEntityDescriptor().isBatchLoadable() ) { if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } // todo (6.0) : subselect fetches similar to batch fetch handling above }
persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); persistenceContext.addProxy( keyToLoad, proxy ); return proxy;