org.hibernate.util.ArrayHelper Java Examples

The following examples show how to use org.hibernate.util.ArrayHelper. 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: 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 #2
Source File: CustomLoader.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void autoDiscoverTypes(ResultSet rs) {
	try {
		Metadata metadata = new Metadata( getFactory(), rs );
		List aliases = new ArrayList();
		List types = new ArrayList();

		rowProcessor.prepareForAutoDiscovery( metadata );

		for ( int i = 0; i < rowProcessor.columnProcessors.length; i++ ) {
			rowProcessor.columnProcessors[i].performDiscovery( metadata, types, aliases );
		}

		resultTypes = ArrayHelper.toTypeArray( types );
		transformerAliases = ArrayHelper.toStringArray( aliases );
	}
	catch ( SQLException e ) {
		throw new HibernateException( "Exception while trying to autodiscover types.", e );
	}
}
 
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: AbstractEntityPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Warning:
 * When there are duplicated property names in the subclasses
 * of the class, this method may return the wrong table
 * number for the duplicated subclass property (note that
 * SingleTableEntityPersister defines an overloaded form
 * which takes the entity name.
 */
public int getSubclassPropertyTableNumber(String propertyPath) {
	String rootPropertyName = StringHelper.root(propertyPath);
	Type type = propertyMapping.toType(rootPropertyName);
	if ( type.isAssociationType() ) {
		AssociationType assocType = ( AssociationType ) type;
		if ( assocType.useLHSPrimaryKey() ) {
			// performance op to avoid the array search
			return 0;
		}
		else if ( type.isCollectionType() ) {
			// properly handle property-ref-based associations
			rootPropertyName = assocType.getLHSPropertyName();
		}
	}
	//Enable for HHH-440, which we don't like:
	/*if ( type.isComponentType() && !propertyName.equals(rootPropertyName) ) {
		String unrooted = StringHelper.unroot(propertyName);
		int idx = ArrayHelper.indexOf( getSubclassColumnClosure(), unrooted );
		if ( idx != -1 ) {
			return getSubclassColumnTableNumberClosure()[idx];
		}
	}*/
	int index = ArrayHelper.indexOf( getSubclassPropertyNameClosure(), rootPropertyName); //TODO: optimize this better!
	return index==-1 ? 0 : getSubclassPropertyTableNumber(index);
}
 
Example #5
Source File: BasicCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Generate the SQL UPDATE that updates a row
 */
protected String generateUpdateRowString() {
	
	Update update = new Update( getDialect() )
		.setTableName( qualifiedTableName );
	
	//if ( !elementIsFormula ) {
		update.addColumns( elementColumnNames, elementColumnIsSettable );
	//}
	
	if ( hasIdentifier ) {
		update.setPrimaryKeyColumnNames( new String[]{ identifierColumnName } );
	}
	else if ( hasIndex && !indexContainsFormula ) {
		update.setPrimaryKeyColumnNames( ArrayHelper.join( keyColumnNames, indexColumnNames ) );
	}
	else {
		update.setPrimaryKeyColumnNames( ArrayHelper.join( keyColumnNames, elementColumnNames, elementColumnIsInPrimaryKey ) );
	}
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		update.setComment( "update collection row " + getRole() );
	}
	
	return update.toStatementString();
}
 
Example #6
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 #7
Source File: BasicCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Generate the SQL DELETE that deletes a particular row
 */
protected String generateDeleteRowString() {
	
	Delete delete = new Delete()
		.setTableName( qualifiedTableName );
	
	if ( hasIdentifier ) {
		delete.setPrimaryKeyColumnNames( new String[]{ identifierColumnName } );
	}
	else if ( hasIndex && !indexContainsFormula ) {
		delete.setPrimaryKeyColumnNames( ArrayHelper.join( keyColumnNames, indexColumnNames ) );
	}
	else {
		delete.setPrimaryKeyColumnNames( ArrayHelper.join( keyColumnNames, elementColumnNames, elementColumnIsInPrimaryKey ) );
	}
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		delete.setComment( "delete collection row " + getRole() );
	}
	
	return delete.toStatementString();
}
 
Example #8
Source File: OneToManyPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Generate the SQL UPDATE that updates a particular row's foreign
 * key to null
 */
protected String generateDeleteRowString() {
	
	Update update = new Update( getDialect() )
			.setTableName( qualifiedTableName )
			.addColumns( keyColumnNames, "null" );
	
	if ( hasIndex && !indexContainsFormula ) update.addColumns( indexColumnNames, "null" );
	
	if ( getFactory().getSettings().isCommentsEnabled() ) {
		update.setComment( "delete one-to-many row " + getRole() );
	}
	
	//use a combination of foreign key columns and pk columns, since
	//the ordering of removal and addition is not guaranteed when
	//a child moves from one parent to another
	String[] rowSelectColumnNames = ArrayHelper.join(keyColumnNames, elementColumnNames);
	return update.setPrimaryKeyColumnNames( rowSelectColumnNames )
			.toStatementString();
}
 
Example #9
Source File: JoinHelper.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Get the aliased columns of the owning entity which are to 
 * be used in the join
 */
public static String[] getAliasedLHSColumnNames(
		AssociationType type, 
		String alias, 
		int property, 
		int begin, 
		OuterJoinLoadable lhsPersister,
		Mapping mapping
) {
	if ( type.useLHSPrimaryKey() ) {
		return StringHelper.qualify( alias, lhsPersister.getIdentifierColumnNames() );
	}
	else {
		String propertyName = type.getLHSPropertyName();
		if (propertyName==null) {
			return ArrayHelper.slice( 
					lhsPersister.toColumns(alias, property), 
					begin, 
					type.getColumnSpan(mapping) 
				);
		}
		else {
			return ( (PropertyMapping) lhsPersister ).toColumns(alias, propertyName); //bad cast
		}
	}
}
 
Example #10
Source File: NativeSQLQuerySpecification.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public NativeSQLQuerySpecification(
		String queryString,
        NativeSQLQueryReturn[] queryReturns,
        Collection querySpaces) {
	this.queryString = queryString;
	this.queryReturns = queryReturns;
	if ( querySpaces == null ) {
		this.querySpaces = Collections.EMPTY_SET;
	}
	else {
		Set tmp = new HashSet();
		tmp.addAll( querySpaces );
		this.querySpaces = Collections.unmodifiableSet( tmp );
	}

	// pre-determine and cache the hashcode
	int hashCode = queryString.hashCode();
	hashCode = 29 * hashCode + this.querySpaces.hashCode();
	if ( this.queryReturns != null ) {
		hashCode = 29 * hashCode + ArrayHelper.toList( this.queryReturns ).hashCode();
	}
	this.hashCode = hashCode;
}
 
Example #11
Source File: ProjectionList.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
	List types = new ArrayList( getLength() );
	for ( int i=0; i<getLength(); i++ ) {
		Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery);
		ArrayHelper.addAll(types, elemTypes);
	}
	return ArrayHelper.toTypeArray(types);
}
 
Example #12
Source File: NativeSQLQueryPlan.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private int[] getNamedParameterLocs(String name) throws QueryException {
	Object loc = customQuery.getNamedParameterBindPoints().get( name );
	if ( loc == null ) {
		throw new QueryException(
				"Named parameter does not appear in Query: " + name,
				customQuery.getSQL() );
	}
	if ( loc instanceof Integer ) {
		return new int[] { ((Integer) loc ).intValue() };
	}
	else {
		return ArrayHelper.toIntArray( (List) loc );
	}
}
 
Example #13
Source File: ProjectionList.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String[] getAliases() {
	List result = new ArrayList( getLength() );
	for ( int i=0; i<getLength(); i++ ) {
		String[] aliases = getProjection(i).getAliases();
		ArrayHelper.addAll(result, aliases);
	}
	return ArrayHelper.toStringArray(result);

}
 
Example #14
Source File: CollectionElementLoader.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CollectionElementLoader(
		QueryableCollection collectionPersister,
		SessionFactoryImplementor factory, 
		Map enabledFilters) 
throws MappingException {
	super(factory, enabledFilters);

	this.keyType = collectionPersister.getKeyType();
	this.indexType = collectionPersister.getIndexType();
	this.persister = (OuterJoinLoadable) collectionPersister.getElementPersister();
	this.entityName = persister.getEntityName();
	
	JoinWalker walker = new EntityJoinWalker(
			persister, 
			ArrayHelper.join( 
					collectionPersister.getKeyColumnNames(), 
					collectionPersister.getIndexColumnNames()
				),
			1, 
			LockMode.NONE, 
			factory, 
			enabledFilters
		);
	initFromWalker( walker );

	postInstantiate();
	
	log.debug( "Static select for entity " + entityName + ": " + getSQLString() );

}
 
Example #15
Source File: ProjectionList.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String[] getColumnAliases(int loc) {
	List result = new ArrayList( getLength() );
	for ( int i=0; i<getLength(); i++ ) {
		String[] colAliases = getProjection(i).getColumnAliases(loc);
		ArrayHelper.addAll(result, colAliases);
		loc+=colAliases.length;
	}
	return ArrayHelper.toStringArray(result);
}
 
Example #16
Source File: AbstractEntityPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Marshall the fields of a persistent instance to a prepared statement
 */
protected int dehydrate(
		final Serializable id,
        final Object[] fields,
        final Object rowId,
        final boolean[] includeProperty,
        final boolean[][] includeColumns,
        final int j,
        final PreparedStatement ps,
        final SessionImplementor session,
        int index) throws SQLException, HibernateException {

	if ( log.isTraceEnabled() ) {
		log.trace( "Dehydrating entity: " + MessageHelper.infoString( this, id, getFactory() ) );
	}

	for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
		if ( includeProperty[i] && isPropertyOfTable( i, j ) ) {
			getPropertyTypes()[i].nullSafeSet( ps, fields[i], index, includeColumns[i], session );
			//index += getPropertyColumnSpan( i );
			index += ArrayHelper.countTrue( includeColumns[i] ); //TODO:  this is kinda slow...
		}
	}

	if ( rowId != null ) {
		ps.setObject( index, rowId );
		index += 1;
	}
	else if ( id != null ) {
		getIdentifierType().nullSafeSet( ps, id, index, session );
		index += getIdentifierColumnSpan();
	}

	return index;

}
 
Example #17
Source File: AbstractCollectionPersister.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Write the element to a JDBC <tt>PreparedStatement</tt>
 */
protected int writeElement(PreparedStatement st, Object elt, int i, SessionImplementor session)
		throws HibernateException, SQLException {
	getElementType().nullSafeSet(st, elt, i, elementColumnIsSettable, session);
	return i + ArrayHelper.countTrue(elementColumnIsSettable);

}
 
Example #18
Source File: JoinHelper.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the columns of the owning entity which are to 
 * be used in the join
 */
public static String[] getLHSColumnNames(
		AssociationType type, 
		int property, 
		int begin, 
		OuterJoinLoadable lhsPersister,
		Mapping mapping
) {
	if ( type.useLHSPrimaryKey() ) {
		//return lhsPersister.getSubclassPropertyColumnNames(property);
		return lhsPersister.getIdentifierColumnNames();
	}
	else {
		String propertyName = type.getLHSPropertyName();
		if (propertyName==null) {
			//slice, to get the columns for this component
			//property
			return ArrayHelper.slice( 
					lhsPersister.getSubclassPropertyColumnNames(property),
					begin, 
					type.getColumnSpan(mapping) 
				);
		}
		else {
			//property-refs for associations defined on a
			//component are not supported, so no need to slice
			return lhsPersister.getPropertyColumnNames(propertyName);
		}
	}
}
 
Example #19
Source File: ExceptionUtils.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * <p>Creates a compact stack trace for the root cause of the supplied
 * <code>Throwable</code>.</p>
 *
 * @param throwable the throwable to examine, may be null
 * @return an array of stack trace frames, never null
 * @since 2.0
 */
public static String[] getRootCauseStackTrace(Throwable throwable) {
	if ( throwable == null ) {
		return ArrayHelper.EMPTY_STRING_ARRAY;
	}
	Throwable throwables[] = getThrowables( throwable );
	int count = throwables.length;
	ArrayList frames = new ArrayList();
	List nextTrace = getStackFrameList( throwables[count - 1] );
	for ( int i = count; --i >= 0; ) {
		List trace = nextTrace;
		if ( i != 0 ) {
			nextTrace = getStackFrameList( throwables[i - 1] );
			removeCommonFrames( trace, nextTrace );
		}
		if ( i == count - 1 ) {
			frames.add( throwables[i].toString() );
		}
		else {
			frames.add( WRAPPED_MARKER + throwables[i].toString() );
		}
		for ( int j = 0; j < trace.size(); j++ ) {
			frames.add( trace.get( j ) );
		}
	}
	return ( String[] ) frames.toArray( new String[0] );
}
 
Example #20
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the names of all entities
 */
public String[] getEntityNames() {
	if (sessionFactory==null) {
		return ArrayHelper.toStringArray( entityStatistics.keySet() );
	}
	else {
		return ArrayHelper.toStringArray( sessionFactory.getAllClassMetadata().keySet() );
	}
}
 
Example #21
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the names of all collection roles
 */
public String[] getCollectionRoleNames() {
	if (sessionFactory==null) {
		return ArrayHelper.toStringArray( collectionStatistics.keySet() );
	}
	else {
		return ArrayHelper.toStringArray( sessionFactory.getAllCollectionMetadata().keySet() );
	}
}
 
Example #22
Source File: StatisticsImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get all second-level cache region names
 */
public String[] getSecondLevelCacheRegionNames() {
	if (sessionFactory==null) {
		return ArrayHelper.toStringArray( secondLevelCacheStatistics.keySet() );
	}
	else {
		return ArrayHelper.toStringArray( sessionFactory.getAllSecondLevelCacheRegions().keySet() );
	}
}
 
Example #23
Source File: IntoClause.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void initializeColumns() {
	AST propertySpec = getFirstChild();
	List types = new ArrayList();
	visitPropertySpecNodes( propertySpec.getFirstChild(), types );
	this.types = ArrayHelper.toTypeArray( types );
	columnSpec = columnSpec.substring( 0, columnSpec.length() - 2 );
}
 
Example #24
Source File: HqlSqlWalker.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns the locations of all occurrences of the named parameter.
 */
public int[] getNamedParameterLocations(String name) throws QueryException {
	Object o = namedParameters.get( name );
	if ( o == null ) {
		QueryException qe = new QueryException( QueryTranslator.ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name );
		qe.setQueryString( queryTranslatorImpl.getQueryString() );
		throw qe;
	}
	if ( o instanceof Integer ) {
		return new int[]{( ( Integer ) o ).intValue()};
	}
	else {
		return ArrayHelper.toIntArray( ( ArrayList ) o );
	}
}
 
Example #25
Source File: QueryTranslatorImpl.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public int[] getNamedParameterLocs(String name) throws QueryException {
	Object o = namedParameters.get( name );
	if ( o == null ) {
		QueryException qe = new QueryException( ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name );
		qe.setQueryString( queryString );
		throw qe;
	}
	if ( o instanceof Integer ) {
		return new int[]{ ( ( Integer ) o ).intValue() };
	}
	else {
		return ArrayHelper.toIntArray( ( ArrayList ) o );
	}
}
 
Example #26
Source File: ComponentType.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void nullSafeSet(
		PreparedStatement st,
		Object value,
		int begin,
		boolean[] settable,
		SessionImplementor session)
		throws HibernateException, SQLException {

	Object[] subvalues = nullSafeGetValues( value, session.getEntityMode() );

	int loc = 0;
	for ( int i = 0; i < propertySpan; i++ ) {
		int len = propertyTypes[i].getColumnSpan( session.getFactory() );
		if ( len == 0 ) {
			//noop
		}
		else if ( len == 1 ) {
			if ( settable[loc] ) {
				propertyTypes[i].nullSafeSet( st, subvalues[i], begin, session );
				begin++;
			}
		}
		else {
			boolean[] subsettable = new boolean[len];
			System.arraycopy( settable, loc, subsettable, 0, len );
			propertyTypes[i].nullSafeSet( st, subvalues[i], begin, subsettable, session );
			begin += ArrayHelper.countTrue( subsettable );
		}
		loc += len;
	}
}
 
Example #27
Source File: ComponentType.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object hydrate(
		final ResultSet rs,
		final String[] names,
		final SessionImplementor session,
		final Object owner)
		throws HibernateException, SQLException {

	int begin = 0;
	boolean notNull = false;
	Object[] values = new Object[propertySpan];
	for ( int i = 0; i < propertySpan; i++ ) {
		int length = propertyTypes[i].getColumnSpan( session.getFactory() );
		String[] range = ArrayHelper.slice( names, begin, length ); //cache this
		Object val = propertyTypes[i].hydrate( rs, range, session, owner );
		if ( val == null ) {
			if ( isKey ) {
				return null; //different nullability rules for pk/fk
			}
		}
		else {
			notNull = true;
		}
		values[i] = val;
		begin += length;
	}

	return notNull ? values : null;
}
 
Example #28
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 #29
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 #30
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 );
}