//TODO think about this scrollmode
return scroll();
}
public List list() throws HibernateException {
SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
//find the directories
IndexSearcher searcher = buildSearcher( searchFactoryImplementor );
if ( searcher == null ) {
return Collections.EMPTY_LIST;
}
try {
QueryHits queryHits = getQueryHits( searcher );
int first = first();
int max = max( first, queryHits.totalHits );
Session sess = ( Session ) this.session;
int size = max - first + 1 < 0 ? 0 : max - first + 1;
List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
DocumentExtractor extractor = new DocumentExtractor(
queryHits, searchFactoryImplementor, indexProjection, idFieldNames, allowFieldSelectionInProjection
);
for ( int index = first; index <= max; index++ ) {
infos.add( extractor.extract( index ) );
}
Loader loader = getLoader( sess, searchFactoryImplementor );
List list = loader.load( infos.toArray( new EntityInfo[infos.size()] ) );
if ( resultTransformer == null || loader instanceof ProjectionLoader ) {
//stay consistent with transformTuple which can only be executed during a projection
return list;
}
else {
return resultTransformer.transformList( list );
}
}
catch ( IOException e ) {
throw new HibernateException( "Unable to query Lucene index", e );
}
finally {
try {
closeSearcher( searcher, searchFactoryImplementor.getReaderProvider() );
}
catch ( SearchException e ) {
log.warn( "Unable to properly close searcher during lucene query: " + getQueryString(), e );
}
}