@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { Serializable[] batch = session.getPersistenceContext().getBatchFetchQueue() .getCollectionBatch( getCollectionPersister(), id, batchSizes[0] ); for ( int i=0; i<batchSizes.length-1; i++) { final int smallBatchSize = batchSizes[i]; if ( batch[smallBatchSize-1]!=null ) { Serializable[] smallBatch = new Serializable[smallBatchSize]; System.arraycopy(batch, 0, smallBatch, 0, smallBatchSize); loaders[i].loadCollectionBatch( session, smallBatch, getCollectionPersister().getKeyType() ); return; //EARLY EXIT! } } loaders[batchSizes.length-1].loadCollection( session, id, getCollectionPersister().getKeyType() ); } }
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { Serializable[] batch = session.getPersistenceContext().getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, batchSizes[0] ); for ( int i=0; i<batchSizes.length-1; i++) { final int smallBatchSize = batchSizes[i]; if ( batch[smallBatchSize-1]!=null ) { Serializable[] smallBatch = new Serializable[smallBatchSize]; System.arraycopy(batch, 0, smallBatch, 0, smallBatchSize); loaders[i].loadCollectionBatch( session, smallBatch, collectionPersister().getKeyType() ); return; //EARLY EXIT! } } loaders[batchSizes.length-1].loadCollection( session, id, collectionPersister().getKeyType() ); } }
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { // first, figure out how many batchable ids we have... final Serializable[] batch = session.getPersistenceContext() .getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, maxBatchSize ); final int numberOfIds = ArrayHelper.countNonNull( batch ); if ( numberOfIds <= 1 ) { singleKeyLoader.loadCollection( session, id, collectionPersister().getKeyType() ); return; } final Serializable[] idsToLoad = new Serializable[numberOfIds]; System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds ); batchLoader.doBatchedCollectionLoad( session, idsToLoad, collectionPersister().getKeyType() ); } }
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { final Serializable[] batch = session.getPersistenceContext() .getBatchFetchQueue() .getCollectionBatch( collectionPersister(), id, batchSizes[0] ); final int numberOfIds = ArrayHelper.countNonNull( batch ); if ( numberOfIds <= 1 ) { loaders[batchSizes.length-1].loadCollection( session, id, collectionPersister().getKeyType() ); return; } // Uses the first batch-size bigger than the number of actual ids in the batch int indexToUse = batchSizes.length-1; for ( int i = 0; i < batchSizes.length-1; i++ ) { if ( batchSizes[i] >= numberOfIds ) { indexToUse = i; } else { break; } } final Serializable[] idsToLoad = new Serializable[ batchSizes[indexToUse] ]; System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds ); for ( int i = numberOfIds; i < batchSizes[indexToUse]; i++ ) { idsToLoad[i] = id; } loaders[indexToUse].loadCollectionBatch( session, idsToLoad, collectionPersister().getKeyType() ); } }
public void initialize(Serializable id, SessionImplementor session) throws HibernateException { Serializable[] batch = session.getPersistenceContext().getBatchFetchQueue() .getCollectionBatch( collectionPersister, id, batchSizes[0] ); for ( int i=0; i<batchSizes.length-1; i++) { final int smallBatchSize = batchSizes[i]; if ( batch[smallBatchSize-1]!=null ) { Serializable[] smallBatch = new Serializable[smallBatchSize]; System.arraycopy(batch, 0, smallBatch, 0, smallBatchSize); loaders[i].loadCollectionBatch( session, smallBatch, collectionPersister.getKeyType() ); return; //EARLY EXIT! } } loaders[batchSizes.length-1].loadCollection( session, id, collectionPersister.getKeyType() ); }
public void initialize(Serializable id, SessionImplementor session) throws HibernateException { Serializable[] batch = session.getPersistenceContext().getBatchFetchQueue() .getCollectionBatch( collectionPersister, id, batchSizes[0] ); for ( int i=0; i<batchSizes.length-1; i++) { final int smallBatchSize = batchSizes[i]; if ( batch[smallBatchSize-1]!=null ) { Serializable[] smallBatch = new Serializable[smallBatchSize]; System.arraycopy(batch, 0, smallBatch, 0, smallBatchSize); loaders[i].loadCollectionBatch( session, smallBatch, collectionPersister.getKeyType() ); return; //EARLY EXIT! } } loaders[batchSizes.length-1].loadCollection( session, id, collectionPersister.getKeyType() ); }