mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
This commit is contained in:
parent
6147c0e0dc
commit
fdcc70dd6c
@ -9,6 +9,8 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mysema.commons.lang.CloseableIterator;
|
||||
|
||||
/**
|
||||
* SimpleProjectable defines a simpler projection interface than {@link Projectable}.
|
||||
*
|
||||
@ -16,6 +18,13 @@ import javax.annotation.Nullable;
|
||||
* @see Projectable
|
||||
*/
|
||||
public interface SimpleProjectable<T> {
|
||||
|
||||
/**
|
||||
* Get the projection as a typed closeable Iterator
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
CloseableIterator<T> iterate();
|
||||
|
||||
/**
|
||||
* Get the projection as a typed List
|
||||
|
||||
@ -7,6 +7,7 @@ package com.mysema.query.support;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mysema.commons.lang.CloseableIterator;
|
||||
import com.mysema.query.Projectable;
|
||||
import com.mysema.query.Query;
|
||||
import com.mysema.query.QueryModifiers;
|
||||
@ -62,6 +63,11 @@ public class SimpleQueryAdapter<T> implements SimpleQuery<SimpleQueryAdapter<T>>
|
||||
query.limit(limit);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloseableIterator<T> iterate(){
|
||||
return projectable.iterate(projection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> list() {
|
||||
|
||||
@ -13,6 +13,8 @@ import org.hibernate.search.FullTextSession;
|
||||
import org.hibernate.search.Search;
|
||||
|
||||
import com.mysema.commons.lang.Assert;
|
||||
import com.mysema.commons.lang.CloseableIterator;
|
||||
import com.mysema.commons.lang.IteratorAdapter;
|
||||
import com.mysema.query.QueryMetadata;
|
||||
import com.mysema.query.QueryModifiers;
|
||||
import com.mysema.query.SearchResults;
|
||||
@ -87,6 +89,11 @@ public class SearchQuery<T> implements SimpleQuery<SearchQuery<T>>, SimpleProjec
|
||||
}
|
||||
return fullTextQuery;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CloseableIterator<T> iterate(){
|
||||
return new IteratorAdapter<T>(createQuery(false).iterate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchQuery<T> limit(long limit) {
|
||||
|
||||
@ -15,6 +15,8 @@ import org.apache.lucene.search.ScoreDoc;
|
||||
import org.apache.lucene.search.Searcher;
|
||||
import org.apache.lucene.search.Sort;
|
||||
|
||||
import com.mysema.commons.lang.CloseableIterator;
|
||||
import com.mysema.commons.lang.IteratorAdapter;
|
||||
import com.mysema.query.QueryException;
|
||||
import com.mysema.query.QueryMetadata;
|
||||
import com.mysema.query.QueryModifiers;
|
||||
@ -78,6 +80,11 @@ public class LuceneQuery implements SimpleQuery<LuceneQuery>, SimpleProjectable<
|
||||
public LuceneQuery limit(long limit) {
|
||||
return queryMixin.limit(limit);
|
||||
}
|
||||
|
||||
public CloseableIterator<Document> iterate(){
|
||||
// TODO : optimize
|
||||
return new IteratorAdapter<Document>(list().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Document> list() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user