org.hibernate.loader.Loader Java Examples

The following examples show how to use org.hibernate.loader.Loader. 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: BatchingEntityLoader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected Object doBatchLoad(
		Serializable id,
		Loader loaderToUse,
		SharedSessionContractImplementor session,
		Serializable[] ids,
		Object optionalObject,
		LockOptions lockOptions) {
	if ( log.isDebugEnabled() ) {
		log.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister, ids, session.getFactory() ) );
	}

	QueryParameters qp = buildQueryParameters( id, ids, optionalObject, lockOptions );

	try {
		final List results = loaderToUse.doQueryAndInitializeNonLazyCollections( session, qp, false );
		log.debug( "Done entity batch load" );
		return getObjectFromList(results, id, session);
	}
	catch ( SQLException sqle ) {
		throw session.getJdbcServices().getSqlExceptionHelper().convert(
				sqle,
				"could not load an entity batch: " + MessageHelper.infoString( persister(), ids, session.getFactory() ),
				loaderToUse.getSQLString()
		);
	}
}
 
Example #2
Source File: AbstractScrollableResults.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public AbstractScrollableResults(
        ResultSet rs,
        PreparedStatement ps,
        SessionImplementor sess,
		Loader loader,
		QueryParameters queryParameters,
        Type[] types,
        HolderInstantiator holderInstantiator) throws MappingException {
	this.resultSet=rs;
	this.ps=ps;
	this.session = sess;
	this.loader = loader;
	this.queryParameters = queryParameters;
	this.types = types;
	this.holderInstantiator = holderInstantiator!=null && holderInstantiator.isRequired()
	        ? holderInstantiator 
	        : null;
}
 
Example #3
Source File: BatchingCollectionInitializer.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static CollectionInitializer createBatchingCollectionInitializer(
	final QueryableCollection persister,
	final int maxBatchSize,
	final SessionFactoryImplementor factory,
	final Map enabledFilters)
throws MappingException {

	if ( maxBatchSize>1 ) {
		int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
		Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
		for ( int i=0; i<batchSizesToCreate.length; i++ ) {
			loadersToCreate[i] = new BasicCollectionLoader(persister, batchSizesToCreate[i], factory, enabledFilters);
		}
		return new BatchingCollectionInitializer(persister, batchSizesToCreate, loadersToCreate);
	}
	else {
		return new BasicCollectionLoader(persister, factory, enabledFilters);
	}
}
 
Example #4
Source File: BatchingCollectionInitializer.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static CollectionInitializer createBatchingOneToManyInitializer(
	final QueryableCollection persister,
	final int maxBatchSize,
	final SessionFactoryImplementor factory,
	final Map enabledFilters)
throws MappingException {

	if ( maxBatchSize>1 ) {
		int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
		Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
		for ( int i=0; i<batchSizesToCreate.length; i++ ) {
			loadersToCreate[i] = new OneToManyLoader(persister, batchSizesToCreate[i], factory, enabledFilters);
		}
		return new BatchingCollectionInitializer(persister, batchSizesToCreate, loadersToCreate);
	}
	else {
		return new OneToManyLoader(persister, factory, enabledFilters);
	}
}
 
Example #5
Source File: BatchingEntityLoader.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static UniqueEntityLoader createBatchingEntityLoader(
	final OuterJoinLoadable persister,
	final int maxBatchSize,
	final LockMode lockMode,
	final SessionFactoryImplementor factory,
	final Map enabledFilters)
throws MappingException {

	if ( maxBatchSize>1 ) {
		int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
		Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
		for ( int i=0; i<batchSizesToCreate.length; i++ ) {
			loadersToCreate[i] = new EntityLoader(persister, batchSizesToCreate[i], lockMode, factory, enabledFilters);
		}
		return new BatchingEntityLoader(persister, batchSizesToCreate, loadersToCreate);
	}
	else {
		return new EntityLoader(persister, lockMode, factory, enabledFilters);
	}
}
 
Example #6
Source File: AbstractScrollableResults.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected AbstractScrollableResults(
		ResultSet rs,
		PreparedStatement ps,
		SharedSessionContractImplementor sess,
		Loader loader,
		QueryParameters queryParameters,
		Type[] types,
		HolderInstantiator holderInstantiator) {
	this.resultSet = rs;
	this.ps = ps;
	this.session = sess;
	this.loader = loader;
	this.queryParameters = queryParameters;
	this.types = types;
	this.holderInstantiator = holderInstantiator != null && holderInstantiator.isRequired()
			? holderInstantiator
			: null;
}
 
Example #7
Source File: LegacyBatchingEntityLoaderBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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);
	}
}
 
Example #8
Source File: BatchingCollectionInitializer.java    From webdsl with Apache License 2.0 5 votes vote down vote up
public static BatchingCollectionInitializer createBatchingCollectionInitializer(
		final QueryableCollection persister,
		final int maxBatchSize,
		final SessionFactoryImplementor factory,
		final LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize > DEFAULT_MAX_BATCH_SIZE ? maxBatchSize : DEFAULT_MAX_BATCH_SIZE);
	Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
	for ( int i=0; i<batchSizesToCreate.length; i++ ) {
		loadersToCreate[i] = new BasicCollectionLoader( persister, batchSizesToCreate[i], factory, loadQueryInfluencers );
	}
	return new BatchingCollectionInitializer(persister, batchSizesToCreate, loadersToCreate, maxBatchSize);
}
 
Example #9
Source File: BatchingCollectionInitializer.java    From webdsl with Apache License 2.0 5 votes vote down vote up
public static BatchingCollectionInitializer createBatchingOneToManyInitializer(
		final QueryableCollection persister,
		final int maxBatchSize,
		final SessionFactoryImplementor factory,
		final LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
	int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize > DEFAULT_MAX_BATCH_SIZE ? maxBatchSize : DEFAULT_MAX_BATCH_SIZE);
	Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
	for ( int i=0; i<batchSizesToCreate.length; i++ ) {
		loadersToCreate[i] = new OneToManyLoader( persister, batchSizesToCreate[i], factory, loadQueryInfluencers );
	}
	return new BatchingCollectionInitializer( persister, batchSizesToCreate, loadersToCreate, maxBatchSize );
}
 
Example #10
Source File: BatchingEntityLoader.java    From webdsl with Apache License 2.0 5 votes vote down vote up
public static BatchingEntityLoader createBatchingEntityLoader(
			final OuterJoinLoadable persister,
			final SessionFactoryImplementor factory) throws MappingException {
			int[] batchSizesToCreate = ArrayHelper.getBatchSizes(DEFAULT_MAX_BATCH_SIZE);
      //System.out.print("created loader");
			Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
			for ( int i=0; i<batchSizesToCreate.length; i++ ) {
				loadersToCreate[i] = new EntityLoader(persister, batchSizesToCreate[i], LockMode.NONE, factory, LoadQueryInfluencers.NONE);
//        System.out.print(", " + batchSizesToCreate[i]);
			}
//      org.webdsl.logging.Logger.info();
			return new BatchingEntityLoader(persister, batchSizesToCreate, loadersToCreate);
	}
 
Example #11
Source File: ScrollableResultsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ScrollableResultsImpl(
        ResultSet rs,
        PreparedStatement ps,
        SessionImplementor sess,
        Loader loader,
        QueryParameters queryParameters,
        Type[] types, HolderInstantiator holderInstantiator) throws MappingException {
	super( rs, ps, sess, loader, queryParameters, types, holderInstantiator );
}
 
Example #12
Source File: FetchingScrollableResultsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public FetchingScrollableResultsImpl(
        ResultSet rs,
        PreparedStatement ps,
        SessionImplementor sess,
        Loader loader,
        QueryParameters queryParameters,
        Type[] types,
        HolderInstantiator holderInstantiator) throws MappingException {
	super( rs, ps, sess, loader, queryParameters, types, holderInstantiator );
}
 
Example #13
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public LegacyBatchingCollectionInitializer(
		QueryableCollection persister,
		int[] batchSizes,
		Loader[] loaders) {
	super( persister );
	this.batchSizes = batchSizes;
	this.loaders = loaders;
}
 
Example #14
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public LegacyBatchingCollectionInitializer(
		QueryableCollection persister,
		int[] batchSizes,
		Loader[] loaders) {
	super( persister );
	this.batchSizes = batchSizes;
	this.loaders = loaders;
}
 
Example #15
Source File: BatchingEntityLoader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected Object doBatchLoad(
		Serializable id,
		Loader loaderToUse,
		SharedSessionContractImplementor session,
		Serializable[] ids,
		Object optionalObject,
		LockOptions lockOptions) {
	if ( log.isDebugEnabled() ) {
		log.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister, ids, session.getFactory() ) );
	}

	QueryParameters qp = buildQueryParameters( id, ids, optionalObject, lockOptions );

	try {
		final List results = loaderToUse.doQueryAndInitializeNonLazyCollections( session, qp, false );
		log.debug( "Done entity batch load" );
		// The EntityKey for any entity that is not found will remain in the batch.
		// Explicitly remove the EntityKeys for entities that were not found to
		// avoid including them in future batches that get executed.
		BatchFetchQueueHelper.removeNotFoundBatchLoadableEntityKeys(
				ids,
				results,
				persister(),
				session
		);
		return getObjectFromList(results, id, session);
	}
	catch ( SQLException sqle ) {
		throw session.getJdbcServices().getSqlExceptionHelper().convert(
				sqle,
				"could not load an entity batch: " + MessageHelper.infoString( persister(), ids, session.getFactory() ),
				loaderToUse.getSQLString()
		);
	}
}
 
Example #16
Source File: LegacyBatchingEntityLoaderBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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);
	}
}
 
Example #17
Source File: PaddedBatchingEntityLoaderBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public PaddedBatchingEntityLoader(
		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);
	}
	validate( maxBatchSize );
}
 
Example #18
Source File: PaddedBatchingEntityLoaderBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public PaddedBatchingEntityLoader(
		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);
	}
	validate( maxBatchSize );
}
 
Example #19
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected 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 #20
Source File: LegacyBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected 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 #21
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 #22
Source File: PaddedBatchingCollectionInitializerBuilder.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 PaddedBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example #23
Source File: PaddedBatchingCollectionInitializerBuilder.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 PaddedBatchingCollectionInitializer( persister, batchSizes, loaders );
}
 
Example #24
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 #25
Source File: BatchingCollectionInitializer.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BatchingCollectionInitializer(CollectionPersister collPersister, int[] batchSizes, Loader[] loaders) {
	this.loaders = loaders;
	this.batchSizes = batchSizes;
	this.collectionPersister = collPersister;
}
 
Example #26
Source File: BatchingEntityLoader.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BatchingEntityLoader(EntityPersister persister, int[] batchSizes, Loader[] loaders) {
	this.batchSizes = batchSizes;
	this.loaders = loaders;
	this.persister = persister;
	idType = persister.getIdentifierType();
}
 
Example #27
Source File: AbstractScrollableResults.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected Loader getLoader() {
	return loader;
}
 
Example #28
Source File: AbstractScrollableResults.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected Loader getLoader() {
	return loader;
}
 
Example #29
Source File: BatchingEntityLoader.java    From webdsl with Apache License 2.0 4 votes vote down vote up
public BatchingEntityLoader(EntityPersister persister, int[] batchSizes, Loader[] loaders) {
	this.batchSizes = batchSizes;
	this.loaders = loaders;
	this.persister = persister;
	idType = persister.getIdentifierType();
}
 
Example #30
Source File: PaddedBatchingCollectionInitializerBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public PaddedBatchingCollectionInitializer(QueryableCollection persister, int[] batchSizes, Loader[] loaders) {
	super( persister );

	this.batchSizes = batchSizes;
	this.loaders = loaders;
}