org.hibernate.loader.entity.UniqueEntityLoader Java Examples
The following examples show how to use
org.hibernate.loader.entity.UniqueEntityLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractEntityPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private UniqueEntityLoader getAppropriateLoader(LockMode lockMode, SessionImplementor session) { final Map enabledFilters = session.getEnabledFilters(); if ( queryLoader != null ) { return queryLoader; } else if ( enabledFilters == null || enabledFilters.isEmpty() ) { if ( session.getFetchProfile()!=null && LockMode.UPGRADE.greaterThan(lockMode) ) { return (UniqueEntityLoader) loaders.get( session.getFetchProfile() ); } else { return (UniqueEntityLoader) loaders.get( lockMode ); } } else { return createEntityLoader( lockMode, enabledFilters ); } }
Example #2
Source File: AbstractBatchingEntityLoaderBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected UniqueEntityLoader buildNonBatchingLoader( OuterJoinLoadable persister, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return EntityLoader.forEntity( persister ).withLockMode( lockMode ).withInfluencers( influencers ).byPrimaryKey(); }
Example #3
Source File: AbstractEntityPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Load an instance using either the <tt>forUpdateLoader</tt> or the outer joining <tt>loader</tt>, * depending upon the value of the <tt>lock</tt> parameter */ public Object load(Serializable id, Object optionalObject, LockMode lockMode, SessionImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "Fetching entity: " + MessageHelper.infoString( this, id, getFactory() ) ); } final UniqueEntityLoader loader = getAppropriateLoader( lockMode, session ); return loader.load( id, optionalObject, session ); }
Example #4
Source File: AbstractEntityPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
private void createLoaders() { loaders.put( LockMode.NONE, createEntityLoader( LockMode.NONE ) ); UniqueEntityLoader readLoader = createEntityLoader( LockMode.READ ); loaders.put( LockMode.READ, readLoader ); //TODO: inexact, what we really need to know is: are any outer joins used? boolean disableForUpdate = getSubclassTableSpan() > 1 && hasSubclasses() && !getFactory().getDialect().supportsOuterJoinForUpdate(); loaders.put( LockMode.UPGRADE, disableForUpdate ? readLoader : createEntityLoader( LockMode.UPGRADE ) ); loaders.put( LockMode.UPGRADE_NOWAIT, disableForUpdate ? readLoader : createEntityLoader( LockMode.UPGRADE_NOWAIT ) ); loaders.put( LockMode.FORCE, disableForUpdate ? readLoader : createEntityLoader( LockMode.FORCE ) ); loaders.put( "merge", new CascadeEntityLoader( this, CascadingAction.MERGE, getFactory() ) ); loaders.put( "refresh", new CascadeEntityLoader( this, CascadingAction.REFRESH, getFactory() ) ); }
Example #5
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
protected UniqueEntityLoader getAppropriateLoader(LockOptions lockOptions, SharedSessionContractImplementor session) { if ( queryLoader != null ) { // if the user specified a custom query loader we need to that // regardless of any other consideration return queryLoader; } else if ( isAffectedByEnabledFilters( session ) ) { // because filters affect the rows returned (because they add // restrictions) these need to be next in precedence return createEntityLoader( lockOptions, session.getLoadQueryInfluencers() ); } else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != null && LockMode.UPGRADE.greaterThan( lockOptions.getLockMode() ) ) { // Next, we consider whether an 'internal' fetch profile has been set. // This indicates a special fetch profile Hibernate needs applied // (for its merge loading process e.g.). return loaders.get( session.getLoadQueryInfluencers().getInternalFetchProfile() ); } else if ( isAffectedByEnabledFetchProfiles( session ) ) { // If the session has associated influencers we need to adjust the // SQL query used for loading based on those influencers return createEntityLoader( lockOptions, session.getLoadQueryInfluencers() ); } else if ( isAffectedByEntityGraph( session ) ) { return createEntityLoader( lockOptions, session.getLoadQueryInfluencers() ); } else if ( lockOptions.getTimeOut() != LockOptions.WAIT_FOREVER ) { return createEntityLoader( lockOptions, session.getLoadQueryInfluencers() ); } else { return getLoaderByLockMode( lockOptions.getLockMode() ); } }
Example #6
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Load an instance using either the <tt>forUpdateLoader</tt> or the outer joining <tt>loader</tt>, * depending upon the value of the <tt>lock</tt> parameter */ public Object load(Serializable id, Object optionalObject, LockOptions lockOptions, SharedSessionContractImplementor session) throws HibernateException { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Fetching entity: {0}", MessageHelper.infoString( this, id, getFactory() ) ); } final UniqueEntityLoader loader = getAppropriateLoader( lockOptions, session ); return loader.load( id, optionalObject, session, lockOptions ); }
Example #7
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
private UniqueEntityLoader generateDelayedEntityLoader(Object lockModeObject) { // Unfortunately, the loaders map mixes LockModes and Strings as keys so we need to accept an Object. // The cast is safe as we will always call this method with a LockMode. LockMode lockMode = (LockMode) lockModeObject; switch ( lockMode ) { case NONE: case READ: case OPTIMISTIC: case OPTIMISTIC_FORCE_INCREMENT: { return createEntityLoader( lockMode ); } case UPGRADE: case UPGRADE_NOWAIT: case UPGRADE_SKIPLOCKED: case FORCE: case PESSIMISTIC_READ: case PESSIMISTIC_WRITE: case PESSIMISTIC_FORCE_INCREMENT: { //TODO: inexact, what we really need to know is: are any outer joins used? boolean disableForUpdate = getSubclassTableSpan() > 1 && hasSubclasses() && !getFactory().getDialect().supportsOuterJoinForUpdate(); return disableForUpdate ? readLockLoader : createEntityLoader( lockMode ); } default: { throw new IllegalStateException( String.format( Locale.ROOT, "Lock mode %1$s not supported by entity loaders.", lockMode ) ); } } }
Example #8
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
protected final UniqueEntityLoader getLoaderByLockMode(LockMode lockMode) { if ( LockMode.NONE == lockMode ) { return noneLockLoader; } else if ( LockMode.READ == lockMode ) { return readLockLoader; } return loaders.computeIfAbsent( lockMode, this::generateDelayedEntityLoader ); }
Example #9
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
protected UniqueEntityLoader createEntityLoader( LockOptions lockOptions, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { //TODO: disable batch loading if lockMode > READ? return BatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockOptions, getFactory(), loadQueryInfluencers ); }
Example #10
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
protected UniqueEntityLoader createEntityLoader( LockMode lockMode, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { //TODO: disable batch loading if lockMode > READ? return BatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockMode, getFactory(), loadQueryInfluencers ); }
Example #11
Source File: LegacyBatchingEntityLoaderBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new LegacyBatchingEntityLoader( persister, batchSize, lockOptions, factory, influencers ); }
Example #12
Source File: LegacyBatchingEntityLoaderBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new LegacyBatchingEntityLoader( persister, batchSize, lockMode, factory, influencers ); }
Example #13
Source File: AbstractBatchingEntityLoaderBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected UniqueEntityLoader buildNonBatchingLoader( OuterJoinLoadable persister, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return EntityLoader.forEntity( persister ).withLockOptions( lockOptions ).withInfluencers( influencers ).byPrimaryKey(); }
Example #14
Source File: ReactiveDynamicBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactiveDynamicBatchingEntityDelegator( persister, batchSize, lockMode, factory, influencers ); }
Example #15
Source File: ReactiveBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
protected UniqueEntityLoader buildNonBatchingLoader( OuterJoinLoadable persister, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactivePlanEntityLoader.Builder( persister ) .withLockMode( lockOptions.getLockMode() ) .withInfluencers( influencers ) .byPrimaryKey(); // return new ReactiveEntityLoader( persister, factory, lockOptions.getLockMode(), influencers); }
Example #16
Source File: ReactiveDynamicBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactiveDynamicBatchingEntityDelegator( persister, batchSize, lockOptions, factory, influencers ); }
Example #17
Source File: ReactivePaddedBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactivePaddedBatchingEntityLoader( persister, batchSize, lockMode, factory, influencers ); }
Example #18
Source File: ReactivePaddedBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactivePaddedBatchingEntityLoader( persister, batchSize, lockOptions, factory, influencers ); }
Example #19
Source File: ReactiveBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
/** * Builds a batch-fetch capable loader based on the given persister, lock-mode, etc. * * @param persister The entity persister * @param batchSize The maximum number of ids to batch-fetch at once * @param lockMode The lock mode * @param factory The SessionFactory * @param influencers Any influencers that should affect the built query * * @return The loader. */ public UniqueEntityLoader buildLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { if ( batchSize <= 1 ) { // no batching return buildNonBatchingLoader( persister, lockMode, factory, influencers ); } return buildBatchingLoader( persister, batchSize, lockMode, factory, influencers ); }
Example #20
Source File: ReactiveBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
protected UniqueEntityLoader buildNonBatchingLoader( OuterJoinLoadable persister, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactivePlanEntityLoader.Builder( persister ) .withLockMode( lockMode ) .withInfluencers( influencers ) .byPrimaryKey(); // return new ReactiveEntityLoader( persister, factory, lockMode, influencers); }
Example #21
Source File: ReactiveBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
/** * Builds a batch-fetch capable loader based on the given persister, lock-options, etc. * * @param persister The entity persister * @param batchSize The maximum number of ids to batch-fetch at once * @param lockOptions The lock options * @param factory The SessionFactory * @param influencers Any influencers that should affect the built query * * @return The loader. */ public UniqueEntityLoader buildLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { if ( batchSize <= 1 ) { // no batching return buildNonBatchingLoader( persister, lockOptions, factory, influencers ); } return buildBatchingLoader( persister, batchSize, lockOptions, factory, influencers ); }
Example #22
Source File: ReactiveBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactiveEntityLoader( persister, factory, lockMode, influencers); }
Example #23
Source File: ReactiveBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new ReactiveEntityLoader( persister, factory, lockOptions.getLockMode(), influencers); }
Example #24
Source File: ReactiveUnionSubclassEntityPersister.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected UniqueEntityLoader createEntityLoader(LockMode lockMode, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return ReactiveBatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockMode, getFactory(), loadQueryInfluencers ); }
Example #25
Source File: ReactiveSingleTableEntityPersister.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected UniqueEntityLoader createEntityLoader(LockMode lockMode, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return ReactiveBatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockMode, getFactory(), loadQueryInfluencers ); }
Example #26
Source File: ReactiveSingleTableEntityPersister.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected UniqueEntityLoader createEntityLoader(LockOptions lockOptions, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return ReactiveBatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockOptions, getFactory(), loadQueryInfluencers ); }
Example #27
Source File: AbstractEntityPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
protected UniqueEntityLoader createEntityLoader(LockMode lockMode, Map enabledFilters) throws MappingException { //TODO: disable batch loading if lockMode > READ? return BatchingEntityLoader.createBatchingEntityLoader( this, batchSize, lockMode, getFactory(), enabledFilters ); }
Example #28
Source File: AbstractEntityPersister.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
protected UniqueEntityLoader createEntityLoader(LockMode lockMode) throws MappingException { return createEntityLoader( lockMode, CollectionHelper.EMPTY_MAP ); }
Example #29
Source File: ReactiveJoinedSubclassEntityPersister.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected UniqueEntityLoader createEntityLoader(LockMode lockMode, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return ReactiveBatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockMode, getFactory(), loadQueryInfluencers ); }
Example #30
Source File: ReactiveJoinedSubclassEntityPersister.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected UniqueEntityLoader createEntityLoader(LockOptions lockOptions, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { return ReactiveBatchingEntityLoaderBuilder.getBuilder( getFactory() ) .buildLoader( this, batchSize, lockOptions, getFactory(), loadQueryInfluencers ); }