mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#217 - ENH: Restore findFutureList() removing its previous deprecated status. Change implementation to use its own PersistenceContext (aka PersistenceContextScope.QUERY)
This commit is contained in:
1 parent
dd30b43d59
commit
8237072f5b
9 files changed
+399
-141
No files matched your search
@@ -54,6 +54,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
this.listAndJoin = " and ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpressionList<?> trimPath(int prefixTrim) {
|
||||
throw new RuntimeException("Only allowed on FilterExpressionList");
|
||||
}
|
||||
@@ -68,6 +69,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
* After deserialisation so that it can be further modified.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void setExpressionFactory(ExpressionFactory expr) {
|
||||
this.expr = expr;
|
||||
}
|
||||
@@ -87,6 +89,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
/**
|
||||
* Return true if one of the expressions is related to a Many property.
|
||||
*/
|
||||
@Override
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins whereManyJoins) {
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
@@ -94,34 +97,42 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> endJunction() {
|
||||
return parentExprList == null ? this : parentExprList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> query() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> where() {
|
||||
return query.where();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderBy<T> order() {
|
||||
return query.order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderBy<T> orderBy() {
|
||||
return query.order();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> order(String orderByClause) {
|
||||
return query.order(orderByClause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> orderBy(String orderBy) {
|
||||
return query.order(orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setOrderBy(String orderBy) {
|
||||
return query.order(orderBy);
|
||||
}
|
||||
@@ -131,14 +142,17 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return query.apply(pathProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FutureIds<T> findFutureIds() {
|
||||
return query.findFutureIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FutureRowCount<T> findFutureRowCount() {
|
||||
return query.findFutureRowCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FutureList<T> findFutureList() {
|
||||
return query.findFutureList();
|
||||
}
|
||||
@@ -148,10 +162,12 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return query.findPagedList(pageIndex, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findRowCount() {
|
||||
return query.findRowCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> findIds() {
|
||||
return query.findIds();
|
||||
}
|
||||
@@ -166,89 +182,100 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
query.findEachWhile(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findVisit(QueryResultVisitor<T> visitor) {
|
||||
query.findVisit(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryIterator<T> findIterate() {
|
||||
return query.findIterate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findList() {
|
||||
return query.findList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<T> findSet() {
|
||||
return query.findSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<?, T> findMap() {
|
||||
return query.findMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K> Map<K, T> findMap(String keyProperty, Class<K> keyType) {
|
||||
return query.findMap(keyProperty, keyType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findUnique() {
|
||||
return query.findUnique();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> filterMany(String prop) {
|
||||
return query.filterMany(prop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> select(String fetchProperties) {
|
||||
return query.select(fetchProperties);
|
||||
}
|
||||
|
||||
public Query<T> join(String assocProperties) {
|
||||
return query.fetch(assocProperties);
|
||||
}
|
||||
|
||||
public Query<T> join(String assocProperty, String assocProperties) {
|
||||
return query.fetch(assocProperty, assocProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setFirstRow(int firstRow) {
|
||||
return query.setFirstRow(firstRow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setMaxRows(int maxRows) {
|
||||
return query.setMaxRows(maxRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setMapKey(String mapKey) {
|
||||
return query.setMapKey(mapKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setUseCache(boolean useCache) {
|
||||
return query.setUseCache(useCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> having() {
|
||||
return query.having();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> add(Expression expr) {
|
||||
list.add((SpiExpression) expr);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> addAll(ExpressionList<T> exprList) {
|
||||
SpiExpressionList<T> spiList = (SpiExpressionList<T>)exprList;
|
||||
list.addAll(spiList.getUnderlyingList());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SpiExpression> getUnderlyingList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildSql(SpiExpressionRequest request) {
|
||||
|
||||
request.append(listAndStart);
|
||||
@@ -263,6 +290,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return request.getSql();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Object> buildBindValues(SpiExpressionRequest request) {
|
||||
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
@@ -288,6 +316,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
* Calculate a hash based on the expressions but excluding the actual bind
|
||||
* values.
|
||||
*/
|
||||
@Override
|
||||
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder) {
|
||||
builder.add(DefaultExpressionList.class);
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
@@ -308,83 +337,99 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> eq(String propertyName, Object value) {
|
||||
add(expr.eq(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> ieq(String propertyName, String value) {
|
||||
add(expr.ieq(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> ne(String propertyName, Object value) {
|
||||
add(expr.ne(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> allEq(Map<String, Object> propertyMap) {
|
||||
add(expr.allEq(propertyMap));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> and(Expression expOne, Expression expTwo) {
|
||||
add(expr.and(expOne, expTwo));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> between(String propertyName, Object value1, Object value2) {
|
||||
add(expr.between(propertyName, value1, value2));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> betweenProperties(String lowProperty, String highProperty, Object value) {
|
||||
add(expr.betweenProperties(lowProperty, highProperty, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Junction<T> conjunction() {
|
||||
Junction<T> conjunction = expr.conjunction(query, this);
|
||||
add(conjunction);
|
||||
return conjunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> contains(String propertyName, String value) {
|
||||
add(expr.contains(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Junction<T> disjunction() {
|
||||
Junction<T> disjunction = expr.disjunction(query, this);
|
||||
add(disjunction);
|
||||
return disjunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> endsWith(String propertyName, String value) {
|
||||
add(expr.endsWith(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> ge(String propertyName, Object value) {
|
||||
add(expr.ge(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> gt(String propertyName, Object value) {
|
||||
add(expr.gt(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> icontains(String propertyName, String value) {
|
||||
add(expr.icontains(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> idIn(List<?> idList) {
|
||||
add(expr.idIn(idList));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> idEq(Object value) {
|
||||
if (query != null && parentExprList == null) {
|
||||
query.setId(value);
|
||||
@@ -394,96 +439,115 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> iendsWith(String propertyName, String value) {
|
||||
add(expr.iendsWith(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> ilike(String propertyName, String value) {
|
||||
add(expr.ilike(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> in(String propertyName, Query<?> subQuery) {
|
||||
add(expr.in(propertyName, subQuery));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> in(String propertyName, Collection<?> values) {
|
||||
add(expr.in(propertyName, values));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> in(String propertyName, Object... values) {
|
||||
add(expr.in(propertyName, values));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> isNotNull(String propertyName) {
|
||||
add(expr.isNotNull(propertyName));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> isNull(String propertyName) {
|
||||
add(expr.isNull(propertyName));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> istartsWith(String propertyName, String value) {
|
||||
add(expr.istartsWith(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> le(String propertyName, Object value) {
|
||||
add(expr.le(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> exampleLike(Object example) {
|
||||
add(expr.exampleLike(example));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> iexampleLike(Object example) {
|
||||
add(expr.iexampleLike(example));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> like(String propertyName, String value) {
|
||||
add(expr.like(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> lt(String propertyName, Object value) {
|
||||
add(expr.lt(propertyName, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> not(Expression exp) {
|
||||
add(expr.not(exp));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> or(Expression expOne, Expression expTwo) {
|
||||
add(expr.or(expOne, expTwo));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> raw(String raw, Object value) {
|
||||
add(expr.raw(raw, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> raw(String raw, Object[] values) {
|
||||
add(expr.raw(raw, values));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> raw(String raw) {
|
||||
add(expr.raw(raw));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> startsWith(String propertyName, String value) {
|
||||
add(expr.startsWith(propertyName, value));
|
||||
return this;
|
||||
|
||||
@@ -11,129 +11,144 @@ import java.util.Set;
|
||||
|
||||
public class FilterExpressionList<T> extends DefaultExpressionList<T> {
|
||||
|
||||
private static final long serialVersionUID = 2226895827150099020L;
|
||||
private static final long serialVersionUID = 2226895827150099020L;
|
||||
|
||||
private final Query<T> rootQuery;
|
||||
|
||||
private final FilterExprPath pathPrefix;
|
||||
private final Query<T> rootQuery;
|
||||
|
||||
public FilterExpressionList(FilterExprPath pathPrefix, FilterExpressionList<T> original) {
|
||||
super(null, original.expr, null, original.getUnderlyingList());
|
||||
this.pathPrefix = pathPrefix;
|
||||
this.rootQuery = original.rootQuery;
|
||||
}
|
||||
|
||||
public FilterExpressionList(FilterExprPath pathPrefix, ExpressionFactory expr, Query<T> rootQuery) {
|
||||
super(null, expr, null);
|
||||
this.pathPrefix = pathPrefix;
|
||||
this.rootQuery = rootQuery;
|
||||
}
|
||||
|
||||
public SpiExpressionList<?> trimPath(int prefixTrim) {
|
||||
return new FilterExpressionList<T>(pathPrefix.trimPath(prefixTrim), this);
|
||||
}
|
||||
|
||||
public FilterExprPath getPathPrefix() {
|
||||
return pathPrefix;
|
||||
}
|
||||
private final FilterExprPath pathPrefix;
|
||||
|
||||
private String notAllowedMessage = "This method is not allowed on a filter";
|
||||
|
||||
public ExpressionList<T> filterMany(String prop) {
|
||||
return rootQuery.filterMany(prop);
|
||||
}
|
||||
|
||||
public FutureIds<T> findFutureIds() {
|
||||
return rootQuery.findFutureIds();
|
||||
}
|
||||
public FilterExpressionList(FilterExprPath pathPrefix, FilterExpressionList<T> original) {
|
||||
super(null, original.expr, null, original.getUnderlyingList());
|
||||
this.pathPrefix = pathPrefix;
|
||||
this.rootQuery = original.rootQuery;
|
||||
}
|
||||
|
||||
public FutureList<T> findFutureList() {
|
||||
return rootQuery.findFutureList();
|
||||
}
|
||||
public FilterExpressionList(FilterExprPath pathPrefix, ExpressionFactory expr, Query<T> rootQuery) {
|
||||
super(null, expr, null);
|
||||
this.pathPrefix = pathPrefix;
|
||||
this.rootQuery = rootQuery;
|
||||
}
|
||||
|
||||
public FutureRowCount<T> findFutureRowCount() {
|
||||
return rootQuery.findFutureRowCount();
|
||||
}
|
||||
@Override
|
||||
public SpiExpressionList<?> trimPath(int prefixTrim) {
|
||||
return new FilterExpressionList<T>(pathPrefix.trimPath(prefixTrim), this);
|
||||
}
|
||||
|
||||
public List<T> findList() {
|
||||
return rootQuery.findList();
|
||||
}
|
||||
public FilterExprPath getPathPrefix() {
|
||||
return pathPrefix;
|
||||
}
|
||||
|
||||
public Map<?, T> findMap() {
|
||||
return rootQuery.findMap();
|
||||
}
|
||||
private String notAllowedMessage = "This method is not allowed on a filter";
|
||||
|
||||
public int findRowCount() {
|
||||
return rootQuery.findRowCount();
|
||||
}
|
||||
@Override
|
||||
public ExpressionList<T> filterMany(String prop) {
|
||||
return rootQuery.filterMany(prop);
|
||||
}
|
||||
|
||||
public Set<T> findSet() {
|
||||
return rootQuery.findSet();
|
||||
}
|
||||
@Override
|
||||
public FutureIds<T> findFutureIds() {
|
||||
return rootQuery.findFutureIds();
|
||||
}
|
||||
|
||||
public T findUnique() {
|
||||
return rootQuery.findUnique();
|
||||
}
|
||||
@Override
|
||||
public FutureList<T> findFutureList() {
|
||||
return rootQuery.findFutureList();
|
||||
}
|
||||
|
||||
public ExpressionList<T> having() {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
@Override
|
||||
public FutureRowCount<T> findFutureRowCount() {
|
||||
return rootQuery.findFutureRowCount();
|
||||
}
|
||||
|
||||
public ExpressionList<T> idEq(Object value) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
@Override
|
||||
public List<T> findList() {
|
||||
return rootQuery.findList();
|
||||
}
|
||||
|
||||
public ExpressionList<T> idIn(List<?> idValues) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
@Override
|
||||
public Map<?, T> findMap() {
|
||||
return rootQuery.findMap();
|
||||
}
|
||||
|
||||
public Query<T> join(String assocProperty, String assocProperties) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
@Override
|
||||
public int findRowCount() {
|
||||
return rootQuery.findRowCount();
|
||||
}
|
||||
|
||||
public Query<T> join(String assocProperties) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
@Override
|
||||
public Set<T> findSet() {
|
||||
return rootQuery.findSet();
|
||||
}
|
||||
|
||||
public OrderBy<T> order() {
|
||||
return rootQuery.order();
|
||||
}
|
||||
@Override
|
||||
public T findUnique() {
|
||||
return rootQuery.findUnique();
|
||||
}
|
||||
|
||||
public Query<T> order(String orderByClause) {
|
||||
return rootQuery.order(orderByClause);
|
||||
}
|
||||
@Override
|
||||
public ExpressionList<T> having() {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
|
||||
public Query<T> orderBy(String orderBy) {
|
||||
return rootQuery.orderBy(orderBy);
|
||||
}
|
||||
@Override
|
||||
public ExpressionList<T> idEq(Object value) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
|
||||
public Query<T> query() {
|
||||
return rootQuery;
|
||||
}
|
||||
@Override
|
||||
public ExpressionList<T> idIn(List<?> idValues) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
|
||||
public Query<T> select(String properties) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
@Override
|
||||
public OrderBy<T> order() {
|
||||
return rootQuery.order();
|
||||
}
|
||||
|
||||
public Query<T> setFirstRow(int firstRow) {
|
||||
return rootQuery.setFirstRow(firstRow);
|
||||
}
|
||||
@Override
|
||||
public Query<T> order(String orderByClause) {
|
||||
return rootQuery.order(orderByClause);
|
||||
}
|
||||
|
||||
public Query<T> setMapKey(String mapKey) {
|
||||
return rootQuery.setMapKey(mapKey);
|
||||
}
|
||||
@Override
|
||||
public Query<T> orderBy(String orderBy) {
|
||||
return rootQuery.orderBy(orderBy);
|
||||
}
|
||||
|
||||
public Query<T> setMaxRows(int maxRows) {
|
||||
return rootQuery.setMaxRows(maxRows);
|
||||
}
|
||||
@Override
|
||||
public Query<T> query() {
|
||||
return rootQuery;
|
||||
}
|
||||
|
||||
public Query<T> setUseCache(boolean useCache) {
|
||||
return rootQuery.setUseCache(useCache);
|
||||
}
|
||||
@Override
|
||||
public Query<T> select(String properties) {
|
||||
throw new PersistenceException(notAllowedMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setFirstRow(int firstRow) {
|
||||
return rootQuery.setFirstRow(firstRow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setMapKey(String mapKey) {
|
||||
return rootQuery.setMapKey(mapKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setMaxRows(int maxRows) {
|
||||
return rootQuery.setMaxRows(maxRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> setUseCache(boolean useCache) {
|
||||
return rootQuery.setUseCache(useCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionList<T> where() {
|
||||
return rootQuery.where();
|
||||
}
|
||||
|
||||
public ExpressionList<T> where() {
|
||||
return rootQuery.where();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user