public EntityJoinWalker( OuterJoinLoadable persister, String[] uniqueKey, int batchSize, LockMode lockMode, final SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, factory, loadQueryInfluencers ); this.lockOptions.setLockMode(lockMode); StringBuilder whereCondition = whereString( getAlias(), uniqueKey, batchSize ) //include the discriminator and class-level where, but not filters .append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) ); AssociationInitCallbackImpl callback = new AssociationInitCallbackImpl( factory ); initAll( whereCondition.toString(), "", lockOptions, callback ); this.compositeKeyManyToOneTargetIndices = callback.resolve(); }
public EntityJoinWalker( OuterJoinLoadable persister, String[] uniqueKey, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, factory, loadQueryInfluencers ); LockOptions.copy(lockOptions, this.lockOptions); StringBuilder whereCondition = whereString( getAlias(), uniqueKey, batchSize ) //include the discriminator and class-level where, but not filters .append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) ); AssociationInitCallbackImpl callback = new AssociationInitCallbackImpl( factory ); initAll( whereCondition.toString(), "", lockOptions, callback ); this.compositeKeyManyToOneTargetIndices = callback.resolve(); }
public CascadeEntityLoader( OuterJoinLoadable persister, CascadingAction action, SessionFactoryImplementor factory) throws MappingException { super( persister, persister.getIdentifierType(), factory, LoadQueryInfluencers.NONE ); JoinWalker walker = new CascadeEntityJoinWalker( persister, action, factory ); initFromWalker( walker ); postInstantiate(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "Static select for action %s on entity %s: %s", action, entityName, getSQLString() ); } }
public EntityLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { this( persister, persister.getIdentifierColumnNames(), persister.getIdentifierType(), batchSize, lockMode, factory, loadQueryInfluencers ); }
public EntityLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { this( persister, persister.getIdentifierColumnNames(), persister.getIdentifierType(), batchSize, lockOptions, factory, loadQueryInfluencers ); }
public LegacyBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); this.loaders = new EntityLoader[ batchSizes.length ]; final EntityLoader.Builder entityLoaderBuilder = EntityLoader.forEntity( persister ) .withInfluencers( loadQueryInfluencers ) .withLockMode( lockMode ); for ( int i = 0; i < batchSizes.length; i++ ) { this.loaders[i] = entityLoaderBuilder.withBatchSize( batchSizes[i] ).byPrimaryKey(); } }
public LegacyBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); this.loaders = new EntityLoader[ batchSizes.length ]; final EntityLoader.Builder entityLoaderBuilder = EntityLoader.forEntity( persister ) .withInfluencers( loadQueryInfluencers ) .withLockOptions( lockOptions ); for ( int i = 0; i < batchSizes.length; i++ ) { this.loaders[i] = entityLoaderBuilder.withBatchSize( batchSizes[i] ).byPrimaryKey(); } }
public BasicCollectionJoinWalker( QueryableCollection collectionPersister, int batchSize, String subquery, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( factory, loadQueryInfluencers ); this.collectionPersister = collectionPersister; String alias = generateRootAlias( collectionPersister.getRole() ); walkCollectionTree(collectionPersister, alias); List allAssociations = new ArrayList(); allAssociations.addAll(associations); allAssociations.add( OuterJoinableAssociation.createRoot( collectionPersister.getCollectionType(), alias, getFactory() ) ); initPersisters(allAssociations, LockMode.NONE); initStatementString(alias, batchSize, subquery); }
public SubselectOneToManyLoader( QueryableCollection persister, String subquery, Collection entityKeys, QueryParameters queryParameters, Map<String, int[]> namedParameterLocMap, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, 1, subquery, factory, loadQueryInfluencers ); keys = new Serializable[ entityKeys.size() ]; Iterator iter = entityKeys.iterator(); int i=0; while ( iter.hasNext() ) { keys[i++] = ( (EntityKey) iter.next() ).getIdentifier(); } this.namedParameters = queryParameters.getNamedParameters(); this.types = queryParameters.getFilteredPositionalParameterTypes(); this.values = queryParameters.getFilteredPositionalParameterValues(); this.namedParameterLocMap = namedParameterLocMap; }
public OneToManyLoader( QueryableCollection oneToManyPersister, int batchSize, String subquery, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( oneToManyPersister, factory, loadQueryInfluencers ); JoinWalker walker = new OneToManyJoinWalker( oneToManyPersister, batchSize, subquery, factory, loadQueryInfluencers ); initFromWalker( walker ); postInstantiate(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "Static select for one-to-many %s: %s", oneToManyPersister.getRole(), getSQLString() ); } }
public DynamicBatchingCollectionInitializer( QueryableCollection collectionPersister, int maxBatchSize, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { super( collectionPersister ); this.maxBatchSize = maxBatchSize; if ( collectionPersister.isOneToMany() ) { this.singleKeyLoader = new OneToManyLoader( collectionPersister, 1, factory, influencers ); } else { this.singleKeyLoader = new BasicCollectionLoader( collectionPersister, 1, factory, influencers ); } this.batchLoader = new DynamicBatchingCollectionLoader( collectionPersister, factory, influencers ); }
public DynamicBatchingCollectionLoader( QueryableCollection collectionPersister, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { super( collectionPersister, factory, influencers ); JoinWalker walker = buildJoinWalker( collectionPersister, factory, influencers ); initFromWalker( walker ); this.sqlTemplate = walker.getSQLString(); this.alias = StringHelper.generateAlias( collectionPersister.getRole(), 0 ); postInstantiate(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "SQL-template for dynamic collection [%s] batch-fetching : %s", collectionPersister.getRole(), sqlTemplate ); } }
public SubselectCollectionLoader( QueryableCollection persister, String subquery, Collection entityKeys, QueryParameters queryParameters, Map<String, int[]> namedParameterLocMap, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, 1, subquery, factory, loadQueryInfluencers ); keys = new Serializable[ entityKeys.size() ]; Iterator iter = entityKeys.iterator(); int i=0; while ( iter.hasNext() ) { keys[i++] = ( (EntityKey) iter.next() ).getIdentifier(); } this.namedParameters = queryParameters.getNamedParameters(); this.types = queryParameters.getFilteredPositionalParameterTypes(); this.values = queryParameters.getFilteredPositionalParameterValues(); this.namedParameterLocMap = namedParameterLocMap; }
public OneToManyJoinWalker( QueryableCollection oneToManyPersister, int batchSize, String subquery, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( factory, loadQueryInfluencers ); this.oneToManyPersister = oneToManyPersister; final OuterJoinLoadable elementPersister = (OuterJoinLoadable) oneToManyPersister.getElementPersister(); final String alias = generateRootAlias( oneToManyPersister.getRole() ); walkEntityTree(elementPersister, alias); List allAssociations = new ArrayList(); allAssociations.addAll(associations); allAssociations.add( OuterJoinableAssociation.createRoot( oneToManyPersister.getCollectionType(), alias, getFactory() ) ); initPersisters(allAssociations, LockMode.NONE); initStatementString(elementPersister, alias, batchSize, subquery); }
public CollectionLoader byKey() { final QueryBuildingParameters buildingParameters = new QueryBuildingParameters() { @Override public LoadQueryInfluencers getQueryInfluencers() { return influencers; } @Override public int getBatchSize() { return batchSize; } @Override public LockMode getLockMode() { return LockMode.NONE; } @Override public LockOptions getLockOptions() { return null; } }; return new CollectionLoader( collectionPersister, buildingParameters ) ; }
protected void createUniqueKeyLoaders() throws MappingException { Type[] propertyTypes = getPropertyTypes(); String[] propertyNames = getPropertyNames(); for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) { if ( propertyUniqueness[i] ) { //don't need filters for the static loaders uniqueKeyLoaders.put( propertyNames[i], createUniqueKeyLoader( propertyTypes[i], getPropertyColumnNames( i ), LoadQueryInfluencers.NONE ) ); //TODO: create uk loaders for component properties } } }
private EntityLoader createUniqueKeyLoader( Type uniqueKeyType, String[] columns, LoadQueryInfluencers loadQueryInfluencers) { if ( uniqueKeyType.isEntityType() ) { String className = ( ( EntityType ) uniqueKeyType ).getAssociatedEntityName(); uniqueKeyType = getFactory().getEntityPersister( className ).getIdentifierType(); } return new EntityLoader( this, columns, uniqueKeyType, 1, LockMode.NONE, getFactory(), loadQueryInfluencers ); }
@Override public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) { final EntityPersister owningPersister = getSource().getEntityPersister(); FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile( loadQueryInfluencers, owningPersister, propertyPath, attributeNumber() ); if ( style == null ) { style = FetchStrategyHelper.determineFetchStyleByMetadata( ( (OuterJoinLoadable) getSource().getEntityPersister() ).getFetchMode( attributeNumber() ), getType(), sessionFactory() ); } return new FetchStrategy( FetchStrategyHelper.determineFetchTiming( style, getType(), sessionFactory() ), style ); }
@Override public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) { final EntityPersister owningPersister = getSource().locateOwningPersister(); FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile( loadQueryInfluencers, owningPersister, propertyPath, attributeNumber() ); if ( style == null ) { style = determineFetchStyleByMetadata( getFetchMode(), getType() ); } return new FetchStrategy( determineFetchTiming( style ), style ); }
public AbstractEntityLoader( OuterJoinLoadable persister, Type uniqueKeyType, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( factory, loadQueryInfluencers ); this.uniqueKeyType = uniqueKeyType; this.entityName = persister.getEntityName(); this.persister = persister; }
/** * 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 ); }
protected UniqueEntityLoader buildNonBatchingLoader( OuterJoinLoadable persister, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new EntityLoader( persister, lockMode, factory, influencers ); }
/** * 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 ); }
protected UniqueEntityLoader buildNonBatchingLoader( OuterJoinLoadable persister, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new EntityLoader( persister, lockOptions, factory, influencers ); }
public EntityLoader( OuterJoinLoadable persister, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { this( persister, 1, lockMode, factory, loadQueryInfluencers ); }
public EntityLoader( OuterJoinLoadable persister, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { this( persister, 1, lockOptions, factory, loadQueryInfluencers ); }
public EntityLoader( OuterJoinLoadable persister, String[] uniqueKey, Type uniqueKeyType, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, uniqueKeyType, factory, loadQueryInfluencers ); EntityJoinWalker walker = new EntityJoinWalker( persister, uniqueKey, batchSize, lockMode, factory, loadQueryInfluencers ); initFromWalker( walker ); this.compositeKeyManyToOneTargetIndices = walker.getCompositeKeyManyToOneTargetIndices(); postInstantiate(); batchLoader = batchSize > 1; if ( LOG.isDebugEnabled() ) { LOG.debugf( "Static select for entity %s [%s]: %s", entityName, lockMode, getSQLString() ); } }
public EntityLoader( OuterJoinLoadable persister, String[] uniqueKey, Type uniqueKeyType, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) throws MappingException { super( persister, uniqueKeyType, factory, loadQueryInfluencers ); EntityJoinWalker walker = new EntityJoinWalker( persister, uniqueKey, batchSize, lockOptions, factory, loadQueryInfluencers ); initFromWalker( walker ); this.compositeKeyManyToOneTargetIndices = walker.getCompositeKeyManyToOneTargetIndices(); postInstantiate(); batchLoader = batchSize > 1; if ( LOG.isDebugEnabled() ) { LOG.debugf( "Static select for entity %s [%s:%s]: %s", entityName, lockOptions.getLockMode(), lockOptions.getTimeOut(), getSQLString() ); } }
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new DynamicBatchingEntityLoader( persister, batchSize, lockMode, factory, influencers ); }
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new DynamicBatchingEntityLoader( persister, batchSize, lockOptions, factory, influencers ); }
public DynamicBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.maxBatchSize = maxBatchSize; this.singleKeyLoader = new EntityLoader( persister, 1, lockMode, factory, loadQueryInfluencers ); this.dynamicLoader = new DynamicEntityLoader( persister, maxBatchSize, lockMode, factory, loadQueryInfluencers ); }
public DynamicBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.maxBatchSize = maxBatchSize; this.singleKeyLoader = new EntityLoader( persister, 1, lockOptions, factory, loadQueryInfluencers ); this.dynamicLoader = new DynamicEntityLoader( persister, maxBatchSize, lockOptions, factory, loadQueryInfluencers ); }
public DynamicEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { this( persister, maxBatchSize, lockOptions.getLockMode(), factory, loadQueryInfluencers ); }
public DynamicEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister, -1, lockMode, factory, loadQueryInfluencers ); EntityJoinWalker walker = new EntityJoinWalker( persister, persister.getIdentifierColumnNames(), -1, lockMode, factory, loadQueryInfluencers ) { @Override protected StringBuilder whereString(String alias, String[] columnNames, int batchSize) { return StringHelper.buildBatchFetchRestrictionFragment( alias, columnNames, getFactory().getDialect() ); } }; initFromWalker( walker ); this.sqlTemplate = walker.getSQLString(); this.alias = walker.getAlias(); postInstantiate(); if ( LOG.isDebugEnabled() ) { LOG.debugf( "SQL-template for dynamic entity [%s] batch-fetching [%s] : %s", entityName, lockMode, sqlTemplate ); } }
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new LegacyBatchingEntityLoader( persister, batchSize, lockMode, factory, influencers ); }
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new LegacyBatchingEntityLoader( persister, batchSize, lockOptions, factory, influencers ); }
public LegacyBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); this.loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { this.loaders[i] = new EntityLoader( persister, batchSizes[i], lockMode, factory, loadQueryInfluencers); } }
public LegacyBatchingEntityLoader( OuterJoinLoadable persister, int maxBatchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) { super( persister ); this.batchSizes = ArrayHelper.getBatchSizes( maxBatchSize ); this.loaders = new Loader[ batchSizes.length ]; for ( int i = 0; i < batchSizes.length; i++ ) { this.loaders[i] = new EntityLoader( persister, batchSizes[i], lockOptions, factory, loadQueryInfluencers); } }
public CascadeEntityJoinWalker(OuterJoinLoadable persister, CascadingAction action, SessionFactoryImplementor factory) throws MappingException { super( persister, factory, LoadQueryInfluencers.NONE ); this.cascadeAction = action; StringBuilder whereCondition = whereString( getAlias(), persister.getIdentifierColumnNames(), 1 ) //include the discriminator and class-level where, but not filters .append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) ); initAll( whereCondition.toString(), "", LockOptions.READ ); }
@Override protected UniqueEntityLoader buildBatchingLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers) { return new PaddedBatchingEntityLoader( persister, batchSize, lockMode, factory, influencers ); }