org.hibernate.loader.collection.CollectionInitializer Java Examples

The following examples show how to use org.hibernate.loader.collection.CollectionInitializer. 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: AbstractCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected CollectionInitializer getAppropriateInitializer(Serializable key, SessionImplementor session) {
	if ( queryLoaderName != null ) {
		//if there is a user-specified loader, return that
		//TODO: filters!?
		return initializer;
	}
	CollectionInitializer subselectInitializer = getSubselectInitializer( key, session );
	if ( subselectInitializer != null ) {
		return subselectInitializer;
	}
	else if ( session.getEnabledFilters().isEmpty() ) {
		return initializer;
	}
	else {
		return createCollectionInitializer( session.getEnabledFilters() );
	}
}
 
Example #2
Source File: AbstractCollectionPersister.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected CollectionInitializer getAppropriateInitializer(Serializable key, SharedSessionContractImplementor session) {
	if ( queryLoaderName != null ) {
		// if there is a user-specified loader, return that
		// TODO: filters!?
		return initializer;
	}
	CollectionInitializer subselectInitializer = getSubselectInitializer( key, session );
	if ( subselectInitializer != null ) {
		return subselectInitializer;
	}
	else if ( session.getLoadQueryInfluencers().getEnabledFilters().isEmpty() ) {
		return initializer;
	}
	else {
		return createCollectionInitializer( session.getLoadQueryInfluencers() );
	}
}
 
Example #3
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollectionInitializer createRealBatchingOneToManyInitializer(
		QueryableCollection persister,
		int maxBatchSize,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	final int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize );
	final Loader[] loaders = new Loader[ batchSizes.length ];
	for ( int i = 0; i < batchSizes.length; i++ ) {
		loaders[i] = new OneToManyLoader( persister, batchSizes[i], factory, loadQueryInfluencers );
	}
	return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example #4
Source File: OneToManyPersister.java    From webdsl with Apache License 2.0 5 votes vote down vote up
protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	if(utils.QueryOptimization.optimizationMode == 3 || utils.QueryOptimization.optimizationMode == 4 || utils.QueryOptimization.optimizationMode == 6) {
		batchInitializer = BatchingCollectionInitializer.createBatchingOneToManyInitializer( this, batchSize, getFactory(), loadQueryInfluencers );
		return batchInitializer;
	}
	return super.createCollectionInitializer(loadQueryInfluencers);
}
 
Example #5
Source File: BasicCollectionPersister.java    From webdsl with Apache License 2.0 5 votes vote down vote up
protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	if(utils.QueryOptimization.optimizationMode == 3 || utils.QueryOptimization.optimizationMode == 4 || utils.QueryOptimization.optimizationMode == 6) {
		batchInitializer = BatchingCollectionInitializer.createBatchingCollectionInitializer( this, batchSize, getFactory(), loadQueryInfluencers );
		return batchInitializer;
	}
	return super.createCollectionInitializer(loadQueryInfluencers);
}
 
Example #6
Source File: AbstractCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private CollectionInitializer getSubselectInitializer(Serializable key, SessionImplementor session) {

		if ( !isSubselectLoadable() ) {
			return null;
		}
		
		final PersistenceContext persistenceContext = session.getPersistenceContext();
		
		SubselectFetch subselect = persistenceContext.getBatchFetchQueue()
			.getSubselect( new EntityKey( key, getOwnerEntityPersister(), session.getEntityMode() ) );
		
		if (subselect == null) {
			return null;
		}
		else {
			
			// Take care of any entities that might have
			// been evicted!	
			Iterator iter = subselect.getResult().iterator();
			while ( iter.hasNext() ) {
				if ( !persistenceContext.containsEntity( (EntityKey) iter.next() ) ) {
					iter.remove();
				}
			}	
			
			// Run a subquery loader
			return createSubselectInitializer( subselect, session );
		}
	}
 
Example #7
Source File: OneToManyPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session) {
	return new SubselectOneToManyLoader( 
			this,
			subselect.toSubselectString( getCollectionType().getLHSPropertyName() ),
			subselect.getResult(),
			subselect.getQueryParameters(),
			subselect.getNamedParameterLocMap(),
			session.getFactory(),
			session.getEnabledFilters() 
		);
}
 
Example #8
Source File: BasicCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session) {
	return new SubselectCollectionLoader( 
			this,
			subselect.toSubselectString( getCollectionType().getLHSPropertyName() ),
			subselect.getResult(),
			subselect.getQueryParameters(),
			subselect.getNamedParameterLocMap(),
			session.getFactory(),
			session.getEnabledFilters() 
		);
}
 
Example #9
Source File: AbstractCollectionPersister.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private CollectionInitializer getSubselectInitializer(Serializable key, SharedSessionContractImplementor session) {

		if ( !isSubselectLoadable() ) {
			return null;
		}

		final PersistenceContext persistenceContext = session.getPersistenceContext();

		SubselectFetch subselect = persistenceContext.getBatchFetchQueue()
				.getSubselect( session.generateEntityKey( key, getOwnerEntityPersister() ) );

		if ( subselect == null ) {
			return null;
		}
		else {

			// Take care of any entities that might have
			// been evicted!
			Iterator iter = subselect.getResult().iterator();
			while ( iter.hasNext() ) {
				if ( !persistenceContext.containsEntity( (EntityKey) iter.next() ) ) {
					iter.remove();
				}
			}

			// Run a subquery loader
			return createSubselectInitializer( subselect, session );
		}
	}
 
Example #10
Source File: OneToManyPersister.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SharedSessionContractImplementor session) {
	return new SubselectOneToManyLoader(
			this,
			subselect.toSubselectString( getCollectionType().getLHSPropertyName() ),
			subselect.getResult(),
			subselect.getQueryParameters(),
			subselect.getNamedParameterLocMap(),
			session.getFactory(),
			session.getLoadQueryInfluencers()
	);
}
 
Example #11
Source File: OneToManyPersister.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the <tt>OneToManyLoader</tt>
 *
 * @see org.hibernate.loader.collection.OneToManyLoader
 */
@Override
protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers)
		throws MappingException {
	return BatchingCollectionInitializerBuilder.getBuilder( getFactory() )
			.createBatchingOneToManyInitializer( this, batchSize, getFactory(), loadQueryInfluencers );
}
 
Example #12
Source File: BasicCollectionPersister.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SharedSessionContractImplementor session) {
	return new SubselectCollectionLoader(
			this,
			subselect.toSubselectString( getCollectionType().getLHSPropertyName() ),
			subselect.getResult(),
			subselect.getQueryParameters(),
			subselect.getNamedParameterLocMap(),
			session.getFactory(),
			session.getLoadQueryInfluencers()
	);
}
 
Example #13
Source File: BasicCollectionPersister.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the <tt>CollectionLoader</tt>
 *
 * @see org.hibernate.loader.collection.BasicCollectionLoader
 */
@Override
protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers)
		throws MappingException {
	return BatchingCollectionInitializerBuilder.getBuilder( getFactory() )
			.createBatchingCollectionInitializer( this, batchSize, getFactory(), loadQueryInfluencers );
}
 
Example #14
Source File: AbstractBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CollectionInitializer buildNonBatchingLoader(
		QueryableCollection persister,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers influencers) {
	return CollectionLoader.forCollection( persister ).withInfluencers( influencers ).byKey();
}
 
Example #15
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollectionInitializer createRealBatchingCollectionInitializer(
		QueryableCollection persister,
		int maxBatchSize,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	int[] batchSizes = ArrayHelper.getBatchSizes( maxBatchSize );
	Loader[] loaders = new Loader[ batchSizes.length ];
	for ( int i = 0; i < batchSizes.length; i++ ) {
		loaders[i] = new BasicCollectionLoader( persister, batchSizes[i], factory, loadQueryInfluencers );
	}
	return new LegacyBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example #16
Source File: AbstractCollectionPersister.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected abstract CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers)
throws MappingException;
 
Example #17
Source File: AbstractCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected abstract CollectionInitializer createCollectionInitializer(Map enabledFilters)
throws MappingException;
 
Example #18
Source File: AbstractCollectionPersister.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Intended for internal use only. In fact really only currently used from
 * test suite for assertion purposes.
 *
 * @return The default collection initializer for this persister/collection.
 */
public CollectionInitializer getInitializer() {
	return initializer;
}
 
Example #19
Source File: BasicCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Create the <tt>CollectionLoader</tt>
 *
 * @see org.hibernate.loader.collection.BasicCollectionLoader
 */
protected CollectionInitializer createCollectionInitializer(java.util.Map enabledFilters)
		throws MappingException {
	return BatchingCollectionInitializer.createBatchingCollectionInitializer( this, batchSize, getFactory(), enabledFilters );
}
 
Example #20
Source File: OneToManyPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Create the <tt>OneToManyLoader</tt>
 *
 * @see org.hibernate.loader.collection.OneToManyLoader
 */
protected CollectionInitializer createCollectionInitializer(java.util.Map enabledFilters) throws MappingException {
	return BatchingCollectionInitializer.createBatchingOneToManyInitializer( this, batchSize, getFactory(), enabledFilters );
}
 
Example #21
Source File: AbstractCollectionPersister.java    From lams with GNU General Public License v2.0 votes vote down vote up
protected abstract CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SharedSessionContractImplementor session); 
Example #22
Source File: AbstractCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 votes vote down vote up
protected abstract CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session);