Add query.apply(PathProperties)

This commit is contained in:
Rob Bygrave
2014-11-12 22:24:37 +13:00
parent eaee3a9c02
commit 2ec50d2c71
6 changed files with 44 additions and 16 deletions
@@ -1,5 +1,7 @@
package com.avaje.ebean;
import com.avaje.ebean.text.PathProperties;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
@@ -87,6 +89,11 @@ public interface ExpressionList<T> extends Serializable {
*/
public Query<T> setOrderBy(String orderBy);
/**
* Apply the path properties to the query replacing the select and fetch clauses.
*/
public Query<T> apply(PathProperties pathProperties);
/**
* Execute the query iterating over the results.
*
@@ -242,7 +249,8 @@ public interface ExpressionList<T> extends Serializable {
* Specify a property (associated bean) to join and <em>fetch</em> including
* all its properties.
*
* @see Query#join(String)
* @see Query#fetch(String)
* @deprecated
*/
public Query<T> join(String assocProperties);
@@ -250,7 +258,8 @@ public interface ExpressionList<T> extends Serializable {
* Specify a property (associated bean) to join and <em>fetch</em> with its
* specific properties to include (aka partial object).
*
* @see Query#join(String,String)
* @see Query#fetch(String,String)
* @deprecated
*/
public Query<T> join(String assocProperty, String assocProperties);
+10
View File
@@ -1,5 +1,7 @@
package com.avaje.ebean;
import com.avaje.ebean.text.PathProperties;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -413,6 +415,14 @@ public interface Query<T> extends Serializable {
*/
public Query<T> fetch(String path, FetchConfig joinConfig);
/**
* Apply the path properties replacing the select and fetch clauses.
* <p>
* This is typically used when the PathProperties is applied to both the query and the JSON output.
* </p>
*/
public Query<T> apply(PathProperties pathProperties);
/**
* Execute the query returning the list of Id's.
* <p>
@@ -5,18 +5,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.avaje.ebean.Expression;
import com.avaje.ebean.ExpressionList;
import com.avaje.ebean.FutureIds;
import com.avaje.ebean.FutureList;
import com.avaje.ebean.FutureRowCount;
import com.avaje.ebean.Junction;
import com.avaje.ebean.OrderBy;
import com.avaje.ebean.PagedList;
import com.avaje.ebean.PagingList;
import com.avaje.ebean.QueryIterator;
import com.avaje.ebean.QueryResultVisitor;
import com.avaje.ebean.*;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebean.text.PathProperties;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.api.ManyWhereJoins;
import com.avaje.ebeaninternal.api.SpiExpression;
@@ -206,6 +197,11 @@ abstract class JunctionExpression<T> implements Junction<T>, SpiExpression, Expr
throw new RuntimeException("filterMany not allowed on Junction expression list");
}
@Override
public Query<T> apply(PathProperties pathProperties) {
return exprList.apply(pathProperties);
}
public FutureIds<T> findFutureIds() {
return exprList.findFutureIds();
}
@@ -31,6 +31,7 @@ import com.avaje.ebean.bean.ObjectGraphNode;
import com.avaje.ebean.bean.ObjectGraphOrigin;
import com.avaje.ebean.bean.PersistenceContext;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebean.text.PathProperties;
import com.avaje.ebeaninternal.api.BindParams;
import com.avaje.ebeaninternal.api.HashQuery;
import com.avaje.ebeaninternal.api.HashQueryPlan;
@@ -270,6 +271,12 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
this.totalHits = totalHits;
}
@Override
public Query<T> apply(PathProperties pathProperties) {
pathProperties.apply(this);
return this;
}
/**
* Set the BeanDescriptor for the root type of this query.
*/
@@ -20,6 +20,7 @@ import com.avaje.ebean.Query;
import com.avaje.ebean.QueryIterator;
import com.avaje.ebean.QueryResultVisitor;
import com.avaje.ebean.event.BeanQueryRequest;
import com.avaje.ebean.text.PathProperties;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.api.ManyWhereJoins;
import com.avaje.ebeaninternal.api.SpiExpression;
@@ -137,6 +138,11 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return query.order(orderBy);
}
@Override
public Query<T> apply(PathProperties pathProperties) {
return query.apply(pathProperties);
}
public FutureIds<T> findFutureIds() {
return query.findFutureIds();
}