From 241a1236b83208a142b4c30ec82fc10c8addf1e4 Mon Sep 17 00:00:00 2001 From: rbygrave Date: Sat, 9 May 2015 01:05:11 +1200 Subject: [PATCH] No effective change - change newline char --- .../avaje/ebeaninternal/api/BeanIdList.java | 190 +-- .../avaje/ebeaninternal/api/BindParams.java | 1008 +++++++------- .../avaje/ebeaninternal/api/ClassUtil.java | 186 +-- .../ebeaninternal/api/HelpScopeTrans.java | 72 +- .../ebeaninternal/api/LoadBeanContext.java | 20 +- .../ebeaninternal/api/LoadBeanRequest.java | 130 +- .../avaje/ebeaninternal/api/LoadContext.java | 126 +- .../ebeaninternal/api/LoadManyContext.java | 18 +- .../ebeaninternal/api/LoadManyRequest.java | 154 +- .../avaje/ebeaninternal/api/LoadRequest.java | 102 +- .../ebeaninternal/api/LoadSecondaryQuery.java | 36 +- .../ebeaninternal/api/ManyWhereJoins.java | 306 ++-- .../com/avaje/ebeaninternal/api/Monitor.java | 24 +- .../avaje/ebeaninternal/api/ScopeTrans.java | 472 +++---- .../ebeaninternal/api/SpiEbeanServer.java | 396 +++--- .../api/SpiExpressionFactory.java | 24 +- .../com/avaje/ebeaninternal/api/SpiQuery.java | 1238 ++++++++--------- .../ebeaninternal/api/SpiTransaction.java | 462 +++--- .../ebeaninternal/api/SpiUpdatePlan.java | 148 +- .../ebeaninternal/api/TransactionEvent.java | 246 ++-- .../api/TransactionEventBeans.java | 80 +- .../jdbc/ConnectionDelegator.java | 508 +++---- .../jdbc/PreparedStatementDelegator.java | 870 ++++++------ .../util/FilterExpressionList.java | 308 ++-- 24 files changed, 3562 insertions(+), 3562 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java index f46215a11..533f5d10a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java @@ -1,95 +1,95 @@ -package com.avaje.ebeaninternal.api; - -import java.util.List; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; - -import javax.persistence.PersistenceException; - -/** - * Wrapper of the list of Id's adding support for background fetching - * future object. - * - * @author rbygrave - */ -public class BeanIdList { - - private final List idList; - - private boolean hasMore = true; - - private FutureTask fetchFuture; - - public BeanIdList(List idList) { - this.idList = idList; - } - - /** - * Return true if the fetch is continuing in a background thread. - */ - public boolean isFetchingInBackground() { - return fetchFuture != null; - } - - /** - * Set the FutureTask that is continuing the fetch in a background thread. - */ - public void setBackgroundFetch(FutureTask fetchFuture) { - this.fetchFuture = fetchFuture; - } - - /** - * Wait for the background fetching to complete with a timeout. - */ - public void backgroundFetchWait(long wait, TimeUnit timeUnit) { - if (fetchFuture != null){ - try { - fetchFuture.get(wait, timeUnit); - } catch (Exception e) { - throw new PersistenceException(e); - } - } - } - - /** - * Wait for the background fetching to complete. - */ - public void backgroundFetchWait() { - if (fetchFuture != null){ - try { - fetchFuture.get(); - } catch (Exception e) { - throw new PersistenceException(e); - } - } - } - - /** - * Add an Id to the list. - */ - public void add(Object id){ - idList.add(id); - } - - /** - * Return the list of Id's. - */ - public List getIdList() { - return idList; - } - - /** - * Return true if max rows was hit and there is more rows to fetch. - */ - public boolean isHasMore() { - return hasMore; - } - - /** - * Set to true when max rows is hit and there are more rows to fetch. - */ - public void setHasMore(boolean hasMore) { - this.hasMore = hasMore; - } - -} +package com.avaje.ebeaninternal.api; + +import java.util.List; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; + +import javax.persistence.PersistenceException; + +/** + * Wrapper of the list of Id's adding support for background fetching + * future object. + * + * @author rbygrave + */ +public class BeanIdList { + + private final List idList; + + private boolean hasMore = true; + + private FutureTask fetchFuture; + + public BeanIdList(List idList) { + this.idList = idList; + } + + /** + * Return true if the fetch is continuing in a background thread. + */ + public boolean isFetchingInBackground() { + return fetchFuture != null; + } + + /** + * Set the FutureTask that is continuing the fetch in a background thread. + */ + public void setBackgroundFetch(FutureTask fetchFuture) { + this.fetchFuture = fetchFuture; + } + + /** + * Wait for the background fetching to complete with a timeout. + */ + public void backgroundFetchWait(long wait, TimeUnit timeUnit) { + if (fetchFuture != null){ + try { + fetchFuture.get(wait, timeUnit); + } catch (Exception e) { + throw new PersistenceException(e); + } + } + } + + /** + * Wait for the background fetching to complete. + */ + public void backgroundFetchWait() { + if (fetchFuture != null){ + try { + fetchFuture.get(); + } catch (Exception e) { + throw new PersistenceException(e); + } + } + } + + /** + * Add an Id to the list. + */ + public void add(Object id){ + idList.add(id); + } + + /** + * Return the list of Id's. + */ + public List getIdList() { + return idList; + } + + /** + * Return true if max rows was hit and there is more rows to fetch. + */ + public boolean isHasMore() { + return hasMore; + } + + /** + * Set to true when max rows is hit and there are more rows to fetch. + */ + public void setHasMore(boolean hasMore) { + this.hasMore = hasMore; + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java index 358bbbf8b..50597f4bd 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java @@ -1,504 +1,504 @@ -package com.avaje.ebeaninternal.api; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; - -/** - * Parameters used for binding to a statement. - *

- * Supports ordered or named parameters. - *

- */ -public class BindParams implements Serializable { - - private static final long serialVersionUID = 4541081933302086285L; - - private List positionedParameters = new ArrayList(); - - private Map namedParameters = new LinkedHashMap(); - - /** - * This is the sql. For named parameters this is the sql after the named - * parameters have been replaced with question mark place holders and the - * parameters have been ordered by addNamedParamInOrder(). - */ - private String preparedSql; - - /** - * Bind hash and count used to detect when the bind values have changed such - * that the generated SQL (with named parameters) needs to be recalculated. - */ - private int[] bindHash; - - public BindParams() { - } - - public int queryBindHash() { - int hc = namedParameters.hashCode(); - for (int i = 0; i < positionedParameters.size(); i++) { - hc = hc * 31 + positionedParameters.get(i).hashCode(); - } - return hc; - } - - /** - * Return the hash that should be included with the query plan. - *

- * This is to handle binding collections to in clauses. The number of values - * in the collection effects the query (number of bind values) and so must be - * taken into account when calculating the query hash. - *

- */ - public void buildQueryPlanHash(HashQueryPlanBuilder builder) { - int[] vals = calcQueryPlanHash(); - builder.add(vals[0]).bind(vals[1]); - } - - /** - * Calculate and return a query plan bind hash with total bind count. - */ - public int[] calcQueryPlanHash() { - int tempBindCount; - int bc = 0; - int hc = 31; - for (Param param : positionedParameters) { - tempBindCount = param.queryBindCount(); - bc += tempBindCount; - hc = hc * 31 + tempBindCount; - } - - for (Map.Entry entry : namedParameters.entrySet()) { - tempBindCount = entry.getValue().queryBindCount(); - bc += tempBindCount; - hc = hc * 31 + entry.getKey().hashCode(); - hc = hc * 31 + tempBindCount; - } - - return new int[]{hc, bc}; - } - - /** - * Return a deep copy of the BindParams. - */ - public BindParams copy() { - BindParams copy = new BindParams(); - for (Param p : positionedParameters) { - copy.positionedParameters.add(p.copy()); - } - for (Entry entry : namedParameters.entrySet()) { - copy.namedParameters.put(entry.getKey(), entry.getValue().copy()); - } - return copy; - } - - /** - * Return true if there are no bind parameters. - */ - public boolean isEmpty() { - return positionedParameters.isEmpty() && namedParameters.isEmpty(); - } - - /** - * Return a Natural Key bind param if supported. - */ - public NaturalKeyBindParam getNaturalKeyBindParam() { - if (positionedParameters != null){ - return null; - } - if (namedParameters != null && namedParameters.size() == 1){ - Entry e = namedParameters.entrySet().iterator().next(); - return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue()); - } - return null; - } - - public int size() { - return positionedParameters.size(); - } - - /** - * Return true if named parameters are being used and they have not yet been - * ordered. The sql needs to be prepared (named replaced with ?) and the - * parameters ordered. - */ - public boolean requiresNamedParamsPrepare() { - return !namedParameters.isEmpty(); - } - - /** - * Set a null parameter using position. - */ - public void setNullParameter(int position, int jdbcType) { - Param p = getParam(position); - p.setInNullType(jdbcType); - } - - /** - * Set an In Out parameter using position. - */ - public void setParameter(int position, Object value, int outType) { - - Param p = getParam(position); - p.setInValue(value); - p.setOutType(outType); - } - - /** - * Using position set the In value of a parameter. Note that for nulls you - * must use setNullParameter. - */ - public void setParameter(int position, Object value) { - - Param p = getParam(position); - p.setInValue(value); - } - - /** - * Register the parameter as an Out parameter using position. - */ - public void registerOut(int position, int outType) { - Param p = getParam(position); - p.setOutType(outType); - } - - private Param getParam(String name) { - Param p = namedParameters.get(name); - if (p == null) { - p = new Param(); - namedParameters.put(name, p); - } - return p; - } - - private Param getParam(int position) { - int more = position - positionedParameters.size(); - if (more > 0) { - for (int i = 0; i < more; i++) { - positionedParameters.add(new Param()); - } - } - return positionedParameters.get(position - 1); - } - - /** - * Set a named In Out parameter. - */ - public void setParameter(String name, Object value, int outType) { - - Param p = getParam(name); - p.setInValue(value); - p.setOutType(outType); - } - - /** - * Set a named In parameter that is null. - */ - public void setNullParameter(String name, int jdbcType) { - Param p = getParam(name); - p.setInNullType(jdbcType); - } - - /** - * Set a named In parameter that is not null. - */ - public Param setParameter(String name, Object value) { - - Param p = getParam(name); - p.setInValue(value); - return p; - } - - /** - * Set an encryption key as a bind value. - *

- * Needs special treatment as the value should not be included in a log. - *

- */ - public Param setEncryptionKey(String name, Object value) { - Param p = getParam(name); - p.setEncryptionKey(value); - return p; - } - - /** - * Register the named parameter as an Out parameter. - */ - public void registerOut(String name, int outType) { - Param p = getParam(name); - p.setOutType(outType); - } - - /** - * Return the Parameter for a given position. - */ - public Param getParameter(int position) { - // Used to read Out value by CallableSql - return getParam(position); - } - - /** - * Return the named parameter. - */ - public Param getParameter(String name) { - return getParam(name); - } - - /** - * Return the values of ordered parameters. - */ - public List positionedParameters() { - return positionedParameters; - } - - /** - * Set the sql with named parameters replaced with place holder ?. - */ - public void setPreparedSql(String preparedSql) { - this.preparedSql = preparedSql; - } - - /** - * Return the sql with ? place holders (named parameters have been processed - * and ordered). - */ - public String getPreparedSql() { - return preparedSql; - } - - /** - * Return true if the bind hash and count has not changed. - */ - public boolean isSameBindHash() { - - if (bindHash == null) { - bindHash = calcQueryPlanHash(); - return false; - } - int[] oldPlan = bindHash; - bindHash = calcQueryPlanHash(); - return bindHash[0] == oldPlan[0] && bindHash[1] == oldPlan[1]; - } - - /** - * Create a new positioned parameters orderedList. - */ - public OrderedList createOrderedList() { - positionedParameters.clear(); - return new OrderedList(positionedParameters); - } - - /** - * The bind parameters in the correct binding order. - *

- * This is the result of converting sql with named parameters - * into sql with ? and ordered parameters. - *

- */ - public static final class OrderedList { - - private final List paramList; - - private final StringBuilder preparedSql; - - public OrderedList() { - this(new ArrayList()); - } - - public OrderedList(List paramList) { - this.paramList = paramList; - this.preparedSql = new StringBuilder(); - } - - /** - * Add a parameter in the correct binding order. - */ - public void add(Param param) { - paramList.add(param); - } - - /** - * Return the number of bind parameters in this list. - */ - public int size() { - return paramList.size(); - } - - /** - * Returns the ordered list of bind parameters. - */ - public List list() { - return paramList; - } - - /** - * Append parsedSql that has named parameters converted into ?. - */ - public void appendSql(String parsedSql) { - preparedSql.append(parsedSql); - } - - public String getPreparedSql() { - return preparedSql.toString(); - } - } - - /** - * A In Out capable parameter for the CallableStatement. - */ - public static final class Param implements Serializable { - - private static final long serialVersionUID = 1L; - - private boolean encryptionKey; - - private boolean isInParam; - - private boolean isOutParam; - - private int type; - - private Object inValue; - - private Object outValue; - - /** - * Construct a Parameter. - */ - public Param() { - } - - public int queryBindCount() { - if (inValue == null) { - return 0; - } - if (inValue instanceof Collection){ - return ((Collection)inValue).size(); - } - return 1; - } - - /** - * Create a deep copy of the Param. - */ - public Param copy() { - Param copy = new Param(); - copy.isInParam = isInParam; - copy.isOutParam = isOutParam; - copy.type = type; - copy.inValue = inValue; - copy.outValue = outValue; - return copy; - } - - public int hashCode() { - int hc = getClass().hashCode(); - hc = hc * 31 + (isInParam ? 0 : 1); - hc = hc * 31 + (isOutParam ? 0 : 1); - hc = hc * 31 + (type); - hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); - return hc; - } - - public boolean equals(Object o) { - return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode()); - } - - /** - * Return true if this is an In parameter that needs to be bound before - * execution. - */ - public boolean isInParam() { - return isInParam; - } - - /** - * Return true if this is an out parameter that needs to be registered - * before execution. - */ - public boolean isOutParam() { - return isOutParam; - } - - /** - * Return the jdbc type of this parameter. Used for registering Out - * parameters and setting NULL In parameters. - */ - public int getType() { - return type; - } - - /** - * Set the Out parameter type. - */ - public void setOutType(int type) { - this.type = type; - this.isOutParam = true; - } - - /** - * Set the In value. - */ - public void setInValue(Object in) { - this.inValue = in; - this.isInParam = true; - } - - /** - * Set an encryption key (which can not be logged). - */ - public void setEncryptionKey(Object in) { - this.inValue = in; - this.isInParam = true; - this.encryptionKey = true; - } - - /** - * Specify that the In parameter is NULL and the specific type that it - * is. - */ - public void setInNullType(int type) { - this.type = type; - this.inValue = null; - this.isInParam = true; - } - - /** - * Return the OUT value that was retrieved. This value is set after - * CallableStatement was executed. - */ - public Object getOutValue() { - return outValue; - } - - /** - * Return the In value. If this is null, then the type should be used to - * specify the type of the null. - */ - public Object getInValue() { - return inValue; - } - - /** - * Set the OUT value returned by a CallableStatement after it has - * executed. - */ - public void setOutValue(Object out) { - this.outValue = out; - } - - /** - * If true do not include this value in a transaction log. - */ - public boolean isEncryptionKey() { - return encryptionKey; - } - - } -} +package com.avaje.ebeaninternal.api; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; + +/** + * Parameters used for binding to a statement. + *

+ * Supports ordered or named parameters. + *

+ */ +public class BindParams implements Serializable { + + private static final long serialVersionUID = 4541081933302086285L; + + private List positionedParameters = new ArrayList(); + + private Map namedParameters = new LinkedHashMap(); + + /** + * This is the sql. For named parameters this is the sql after the named + * parameters have been replaced with question mark place holders and the + * parameters have been ordered by addNamedParamInOrder(). + */ + private String preparedSql; + + /** + * Bind hash and count used to detect when the bind values have changed such + * that the generated SQL (with named parameters) needs to be recalculated. + */ + private int[] bindHash; + + public BindParams() { + } + + public int queryBindHash() { + int hc = namedParameters.hashCode(); + for (int i = 0; i < positionedParameters.size(); i++) { + hc = hc * 31 + positionedParameters.get(i).hashCode(); + } + return hc; + } + + /** + * Return the hash that should be included with the query plan. + *

+ * This is to handle binding collections to in clauses. The number of values + * in the collection effects the query (number of bind values) and so must be + * taken into account when calculating the query hash. + *

+ */ + public void buildQueryPlanHash(HashQueryPlanBuilder builder) { + int[] vals = calcQueryPlanHash(); + builder.add(vals[0]).bind(vals[1]); + } + + /** + * Calculate and return a query plan bind hash with total bind count. + */ + public int[] calcQueryPlanHash() { + int tempBindCount; + int bc = 0; + int hc = 31; + for (Param param : positionedParameters) { + tempBindCount = param.queryBindCount(); + bc += tempBindCount; + hc = hc * 31 + tempBindCount; + } + + for (Map.Entry entry : namedParameters.entrySet()) { + tempBindCount = entry.getValue().queryBindCount(); + bc += tempBindCount; + hc = hc * 31 + entry.getKey().hashCode(); + hc = hc * 31 + tempBindCount; + } + + return new int[]{hc, bc}; + } + + /** + * Return a deep copy of the BindParams. + */ + public BindParams copy() { + BindParams copy = new BindParams(); + for (Param p : positionedParameters) { + copy.positionedParameters.add(p.copy()); + } + for (Entry entry : namedParameters.entrySet()) { + copy.namedParameters.put(entry.getKey(), entry.getValue().copy()); + } + return copy; + } + + /** + * Return true if there are no bind parameters. + */ + public boolean isEmpty() { + return positionedParameters.isEmpty() && namedParameters.isEmpty(); + } + + /** + * Return a Natural Key bind param if supported. + */ + public NaturalKeyBindParam getNaturalKeyBindParam() { + if (positionedParameters != null){ + return null; + } + if (namedParameters != null && namedParameters.size() == 1){ + Entry e = namedParameters.entrySet().iterator().next(); + return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue()); + } + return null; + } + + public int size() { + return positionedParameters.size(); + } + + /** + * Return true if named parameters are being used and they have not yet been + * ordered. The sql needs to be prepared (named replaced with ?) and the + * parameters ordered. + */ + public boolean requiresNamedParamsPrepare() { + return !namedParameters.isEmpty(); + } + + /** + * Set a null parameter using position. + */ + public void setNullParameter(int position, int jdbcType) { + Param p = getParam(position); + p.setInNullType(jdbcType); + } + + /** + * Set an In Out parameter using position. + */ + public void setParameter(int position, Object value, int outType) { + + Param p = getParam(position); + p.setInValue(value); + p.setOutType(outType); + } + + /** + * Using position set the In value of a parameter. Note that for nulls you + * must use setNullParameter. + */ + public void setParameter(int position, Object value) { + + Param p = getParam(position); + p.setInValue(value); + } + + /** + * Register the parameter as an Out parameter using position. + */ + public void registerOut(int position, int outType) { + Param p = getParam(position); + p.setOutType(outType); + } + + private Param getParam(String name) { + Param p = namedParameters.get(name); + if (p == null) { + p = new Param(); + namedParameters.put(name, p); + } + return p; + } + + private Param getParam(int position) { + int more = position - positionedParameters.size(); + if (more > 0) { + for (int i = 0; i < more; i++) { + positionedParameters.add(new Param()); + } + } + return positionedParameters.get(position - 1); + } + + /** + * Set a named In Out parameter. + */ + public void setParameter(String name, Object value, int outType) { + + Param p = getParam(name); + p.setInValue(value); + p.setOutType(outType); + } + + /** + * Set a named In parameter that is null. + */ + public void setNullParameter(String name, int jdbcType) { + Param p = getParam(name); + p.setInNullType(jdbcType); + } + + /** + * Set a named In parameter that is not null. + */ + public Param setParameter(String name, Object value) { + + Param p = getParam(name); + p.setInValue(value); + return p; + } + + /** + * Set an encryption key as a bind value. + *

+ * Needs special treatment as the value should not be included in a log. + *

+ */ + public Param setEncryptionKey(String name, Object value) { + Param p = getParam(name); + p.setEncryptionKey(value); + return p; + } + + /** + * Register the named parameter as an Out parameter. + */ + public void registerOut(String name, int outType) { + Param p = getParam(name); + p.setOutType(outType); + } + + /** + * Return the Parameter for a given position. + */ + public Param getParameter(int position) { + // Used to read Out value by CallableSql + return getParam(position); + } + + /** + * Return the named parameter. + */ + public Param getParameter(String name) { + return getParam(name); + } + + /** + * Return the values of ordered parameters. + */ + public List positionedParameters() { + return positionedParameters; + } + + /** + * Set the sql with named parameters replaced with place holder ?. + */ + public void setPreparedSql(String preparedSql) { + this.preparedSql = preparedSql; + } + + /** + * Return the sql with ? place holders (named parameters have been processed + * and ordered). + */ + public String getPreparedSql() { + return preparedSql; + } + + /** + * Return true if the bind hash and count has not changed. + */ + public boolean isSameBindHash() { + + if (bindHash == null) { + bindHash = calcQueryPlanHash(); + return false; + } + int[] oldPlan = bindHash; + bindHash = calcQueryPlanHash(); + return bindHash[0] == oldPlan[0] && bindHash[1] == oldPlan[1]; + } + + /** + * Create a new positioned parameters orderedList. + */ + public OrderedList createOrderedList() { + positionedParameters.clear(); + return new OrderedList(positionedParameters); + } + + /** + * The bind parameters in the correct binding order. + *

+ * This is the result of converting sql with named parameters + * into sql with ? and ordered parameters. + *

+ */ + public static final class OrderedList { + + private final List paramList; + + private final StringBuilder preparedSql; + + public OrderedList() { + this(new ArrayList()); + } + + public OrderedList(List paramList) { + this.paramList = paramList; + this.preparedSql = new StringBuilder(); + } + + /** + * Add a parameter in the correct binding order. + */ + public void add(Param param) { + paramList.add(param); + } + + /** + * Return the number of bind parameters in this list. + */ + public int size() { + return paramList.size(); + } + + /** + * Returns the ordered list of bind parameters. + */ + public List list() { + return paramList; + } + + /** + * Append parsedSql that has named parameters converted into ?. + */ + public void appendSql(String parsedSql) { + preparedSql.append(parsedSql); + } + + public String getPreparedSql() { + return preparedSql.toString(); + } + } + + /** + * A In Out capable parameter for the CallableStatement. + */ + public static final class Param implements Serializable { + + private static final long serialVersionUID = 1L; + + private boolean encryptionKey; + + private boolean isInParam; + + private boolean isOutParam; + + private int type; + + private Object inValue; + + private Object outValue; + + /** + * Construct a Parameter. + */ + public Param() { + } + + public int queryBindCount() { + if (inValue == null) { + return 0; + } + if (inValue instanceof Collection){ + return ((Collection)inValue).size(); + } + return 1; + } + + /** + * Create a deep copy of the Param. + */ + public Param copy() { + Param copy = new Param(); + copy.isInParam = isInParam; + copy.isOutParam = isOutParam; + copy.type = type; + copy.inValue = inValue; + copy.outValue = outValue; + return copy; + } + + public int hashCode() { + int hc = getClass().hashCode(); + hc = hc * 31 + (isInParam ? 0 : 1); + hc = hc * 31 + (isOutParam ? 0 : 1); + hc = hc * 31 + (type); + hc = hc * 31 + (inValue == null ? 0 : inValue.hashCode()); + return hc; + } + + public boolean equals(Object o) { + return o != null && (o == this || (o instanceof Param) && hashCode() == o.hashCode()); + } + + /** + * Return true if this is an In parameter that needs to be bound before + * execution. + */ + public boolean isInParam() { + return isInParam; + } + + /** + * Return true if this is an out parameter that needs to be registered + * before execution. + */ + public boolean isOutParam() { + return isOutParam; + } + + /** + * Return the jdbc type of this parameter. Used for registering Out + * parameters and setting NULL In parameters. + */ + public int getType() { + return type; + } + + /** + * Set the Out parameter type. + */ + public void setOutType(int type) { + this.type = type; + this.isOutParam = true; + } + + /** + * Set the In value. + */ + public void setInValue(Object in) { + this.inValue = in; + this.isInParam = true; + } + + /** + * Set an encryption key (which can not be logged). + */ + public void setEncryptionKey(Object in) { + this.inValue = in; + this.isInParam = true; + this.encryptionKey = true; + } + + /** + * Specify that the In parameter is NULL and the specific type that it + * is. + */ + public void setInNullType(int type) { + this.type = type; + this.inValue = null; + this.isInParam = true; + } + + /** + * Return the OUT value that was retrieved. This value is set after + * CallableStatement was executed. + */ + public Object getOutValue() { + return outValue; + } + + /** + * Return the In value. If this is null, then the type should be used to + * specify the type of the null. + */ + public Object getInValue() { + return inValue; + } + + /** + * Set the OUT value returned by a CallableStatement after it has + * executed. + */ + public void setOutValue(Object out) { + this.outValue = out; + } + + /** + * If true do not include this value in a transaction log. + */ + public boolean isEncryptionKey() { + return encryptionKey; + } + + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java index ba703293b..4d4a3c3c7 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java @@ -1,93 +1,93 @@ -package com.avaje.ebeaninternal.api; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Helper to find classes taking into account the context class loader. - * - * @author rbygrave - */ -public class ClassUtil { - - private static final Logger logger = LoggerFactory.getLogger(ClassUtil.class); - - private static boolean preferContext = true; - - /** - * Load a class taking into account a context class loader (if present). - */ - public static Class forName(String name) throws ClassNotFoundException { - return forName(name, null); - } - - /** - * Load a class taking into account a context class loader (if present). - */ - public static Class forName(String name, Class caller) throws ClassNotFoundException { - - if (caller == null){ - caller = ClassUtil.class; - } - ClassLoadContext ctx = ClassLoadContext.of(caller, preferContext); - - return ctx.forName(name); - } - - - public static ClassLoader getClassLoader(Class caller, boolean preferContext) { - - if (caller == null){ - caller = ClassUtil.class; - } - ClassLoadContext ctx = ClassLoadContext.of(caller, preferContext); - ClassLoader classLoader = ctx.getDefault(preferContext); - if (ctx.isAmbiguous()){ - logger.info("Ambigous ClassLoader (Context vs Caller) chosen "+classLoader); - } - return classLoader; - } - - /** - * Return true if the given class is present. - */ - public static boolean isPresent(String className) { - return isPresent(className, null); - } - - /** - * Return true if the given class is present. - */ - public static boolean isPresent(String className, Class caller) { - try { - forName(className, caller); - return true; - } catch (Throwable ex) { - // Class or one of its dependencies is not present... - return false; - } - } - - /** - * Return a new instance of the class using the default constructor. - */ - public static Object newInstance(String className) { - return newInstance(className,null); - } - - /** - * Return a new instance of the class using the default constructor. - */ - public static Object newInstance(String className, Class caller) { - - try { - Class cls = forName(className, caller); - return cls.newInstance(); - } catch (Exception e){ - String msg = "Error constructing "+className; - throw new IllegalArgumentException(msg, e); - } - } -} - +package com.avaje.ebeaninternal.api; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Helper to find classes taking into account the context class loader. + * + * @author rbygrave + */ +public class ClassUtil { + + private static final Logger logger = LoggerFactory.getLogger(ClassUtil.class); + + private static boolean preferContext = true; + + /** + * Load a class taking into account a context class loader (if present). + */ + public static Class forName(String name) throws ClassNotFoundException { + return forName(name, null); + } + + /** + * Load a class taking into account a context class loader (if present). + */ + public static Class forName(String name, Class caller) throws ClassNotFoundException { + + if (caller == null){ + caller = ClassUtil.class; + } + ClassLoadContext ctx = ClassLoadContext.of(caller, preferContext); + + return ctx.forName(name); + } + + + public static ClassLoader getClassLoader(Class caller, boolean preferContext) { + + if (caller == null){ + caller = ClassUtil.class; + } + ClassLoadContext ctx = ClassLoadContext.of(caller, preferContext); + ClassLoader classLoader = ctx.getDefault(preferContext); + if (ctx.isAmbiguous()){ + logger.info("Ambigous ClassLoader (Context vs Caller) chosen "+classLoader); + } + return classLoader; + } + + /** + * Return true if the given class is present. + */ + public static boolean isPresent(String className) { + return isPresent(className, null); + } + + /** + * Return true if the given class is present. + */ + public static boolean isPresent(String className, Class caller) { + try { + forName(className, caller); + return true; + } catch (Throwable ex) { + // Class or one of its dependencies is not present... + return false; + } + } + + /** + * Return a new instance of the class using the default constructor. + */ + public static Object newInstance(String className) { + return newInstance(className,null); + } + + /** + * Return a new instance of the class using the default constructor. + */ + public static Object newInstance(String className, Class caller) { + + try { + Class cls = forName(className, caller); + return cls.newInstance(); + } catch (Exception e){ + String msg = "Error constructing "+className; + throw new IllegalArgumentException(msg, e); + } + } +} + diff --git a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java index 5a73c7063..abc111d61 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java @@ -1,36 +1,36 @@ -package com.avaje.ebeaninternal.api; - -import com.avaje.ebean.Ebean; -import com.avaje.ebean.EbeanServer; -import com.avaje.ebean.TxScope; - -/** - * Helper object to make AOP generated code simpler. - */ -public class HelpScopeTrans { - - /** - * Create a ScopeTrans for a given methods TxScope. - */ - public static ScopeTrans createScopeTrans(TxScope txScope) { - - EbeanServer server = Ebean.getServer(txScope.getServerName()); - SpiEbeanServer iserver = (SpiEbeanServer)server; - return iserver.createScopeTrans(txScope); - } - - /** - * Exiting the method in an expected fashion. - *

- * That is returning successfully or via a caught exception. - * Unexpected exceptions are caught via the Thread uncaughtExceptionHandler. - *

- * @param returnOrThrowable the return or throwable object - * @param opCode the opcode for ATHROW or ARETURN etc - * @param scopeTrans the scoped transaction the method was run with. - */ - public static void onExitScopeTrans(Object returnOrThrowable, int opCode, ScopeTrans scopeTrans){ - - scopeTrans.onExit(returnOrThrowable, opCode); - } -} +package com.avaje.ebeaninternal.api; + +import com.avaje.ebean.Ebean; +import com.avaje.ebean.EbeanServer; +import com.avaje.ebean.TxScope; + +/** + * Helper object to make AOP generated code simpler. + */ +public class HelpScopeTrans { + + /** + * Create a ScopeTrans for a given methods TxScope. + */ + public static ScopeTrans createScopeTrans(TxScope txScope) { + + EbeanServer server = Ebean.getServer(txScope.getServerName()); + SpiEbeanServer iserver = (SpiEbeanServer)server; + return iserver.createScopeTrans(txScope); + } + + /** + * Exiting the method in an expected fashion. + *

+ * That is returning successfully or via a caught exception. + * Unexpected exceptions are caught via the Thread uncaughtExceptionHandler. + *

+ * @param returnOrThrowable the return or throwable object + * @param opCode the opcode for ATHROW or ARETURN etc + * @param scopeTrans the scoped transaction the method was run with. + */ + public static void onExitScopeTrans(Object returnOrThrowable, int opCode, ScopeTrans scopeTrans){ + + scopeTrans.onExit(returnOrThrowable, opCode); + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java index cb99e4ff2..f38b43189 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java @@ -1,10 +1,10 @@ -package com.avaje.ebeaninternal.api; - - -/** - * Controls the loading of ManyToOne and OneToOne relationships. - */ -public interface LoadBeanContext extends LoadSecondaryQuery { - - -} +package com.avaje.ebeaninternal.api; + + +/** + * Controls the loading of ManyToOne and OneToOne relationships. + */ +public interface LoadBeanContext extends LoadSecondaryQuery { + + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java index e3af79aa4..9950fbf8c 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanRequest.java @@ -1,65 +1,65 @@ -package com.avaje.ebeaninternal.api; - -import java.util.List; - -import com.avaje.ebean.bean.EntityBeanIntercept; -import com.avaje.ebeaninternal.server.core.OrmQueryRequest; - -/** - * Request for loading ManyToOne and OneToOne relationships. - */ -public class LoadBeanRequest extends LoadRequest { - - private final List batch; - - private final LoadBeanBuffer LoadBuffer; - - private final String lazyLoadProperty; - - private final boolean loadCache; - - public LoadBeanRequest(LoadBeanBuffer LoadBuffer, boolean lazy, String lazyLoadProperty, boolean loadCache) { - this(LoadBuffer, null, lazy, lazyLoadProperty, loadCache); - } - - public LoadBeanRequest(LoadBeanBuffer LoadBuffer, OrmQueryRequest parentRequest, boolean lazy, String lazyLoadProperty, boolean loadCache) { - super(parentRequest, lazy); - this.LoadBuffer = LoadBuffer; - this.batch = LoadBuffer.getBatch(); - this.lazyLoadProperty = lazyLoadProperty; - this.loadCache = loadCache; - } - - public boolean isLoadCache() { - return loadCache; - } - - public String getDescription() { - return "path:" + LoadBuffer.getFullPath() + " batch:" + batch.size(); - } - - /** - * Return the batch of beans to actually load. - */ - public List getBatch() { - return batch; - } - - /** - * Return the load context. - */ - public LoadBeanBuffer getLoadContext() { - return LoadBuffer; - } - - /** - * Return the property that invoked the lazy loading. - */ - public String getLazyLoadProperty() { - return lazyLoadProperty; - } - - public int getBatchSize() { - return getLoadContext().getBatchSize(); - } -} +package com.avaje.ebeaninternal.api; + +import java.util.List; + +import com.avaje.ebean.bean.EntityBeanIntercept; +import com.avaje.ebeaninternal.server.core.OrmQueryRequest; + +/** + * Request for loading ManyToOne and OneToOne relationships. + */ +public class LoadBeanRequest extends LoadRequest { + + private final List batch; + + private final LoadBeanBuffer LoadBuffer; + + private final String lazyLoadProperty; + + private final boolean loadCache; + + public LoadBeanRequest(LoadBeanBuffer LoadBuffer, boolean lazy, String lazyLoadProperty, boolean loadCache) { + this(LoadBuffer, null, lazy, lazyLoadProperty, loadCache); + } + + public LoadBeanRequest(LoadBeanBuffer LoadBuffer, OrmQueryRequest parentRequest, boolean lazy, String lazyLoadProperty, boolean loadCache) { + super(parentRequest, lazy); + this.LoadBuffer = LoadBuffer; + this.batch = LoadBuffer.getBatch(); + this.lazyLoadProperty = lazyLoadProperty; + this.loadCache = loadCache; + } + + public boolean isLoadCache() { + return loadCache; + } + + public String getDescription() { + return "path:" + LoadBuffer.getFullPath() + " batch:" + batch.size(); + } + + /** + * Return the batch of beans to actually load. + */ + public List getBatch() { + return batch; + } + + /** + * Return the load context. + */ + public LoadBeanBuffer getLoadContext() { + return LoadBuffer; + } + + /** + * Return the property that invoked the lazy loading. + */ + public String getLazyLoadProperty() { + return lazyLoadProperty; + } + + public int getBatchSize() { + return getLoadContext().getBatchSize(); + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadContext.java index f54e02e26..ac999599d 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadContext.java @@ -1,63 +1,63 @@ -package com.avaje.ebeaninternal.api; - -import com.avaje.ebean.bean.BeanCollection; -import com.avaje.ebean.bean.EntityBeanIntercept; -import com.avaje.ebean.bean.ObjectGraphNode; -import com.avaje.ebean.bean.PersistenceContext; -import com.avaje.ebeaninternal.server.core.OrmQueryRequest; - -/** - * Controls the loading of reference objects for a query instance. - */ -public interface LoadContext { - - /** - * Return the minimum batch size when using QueryIterator with query joins. - */ - public int getSecondaryQueriesMinBatchSize(OrmQueryRequest parentRequest, int defaultQueryBatch); - - /** - * Execute any secondary (+query) queries if there are any defined. - * @param parentRequest the originating query request - */ - public void executeSecondaryQueries(OrmQueryRequest parentRequest); - - /** - * Register any secondary queries (+query or +lazy) with their - * appropriate LoadBeanContext or LoadManyContext. - *

- * This is so the LoadBeanContext or LoadManyContext use the - * defined query for +query and +lazy execution. - *

- */ - public void registerSecondaryQueries(SpiQuery query); - - /** - * Return the node for a given path which is used by autofetch profiling. - */ - public ObjectGraphNode getObjectGraphNode(String path); - - /** - * Return the persistence context used by this query and future lazy loading. - */ - public PersistenceContext getPersistenceContext(); - - /** - * Set the persistence context used by this query and future lazy loading. - *

- * Used by query iterator when processing large result sets. - *

- */ - public void resetPersistenceContext(PersistenceContext persistenceContext); - - /** - * Register a Bean for lazy loading. - */ - public void register(String path, EntityBeanIntercept ebi); - - /** - * Register a collection for lazy loading. - */ - public void register(String path, BeanCollection bc); - -} +package com.avaje.ebeaninternal.api; + +import com.avaje.ebean.bean.BeanCollection; +import com.avaje.ebean.bean.EntityBeanIntercept; +import com.avaje.ebean.bean.ObjectGraphNode; +import com.avaje.ebean.bean.PersistenceContext; +import com.avaje.ebeaninternal.server.core.OrmQueryRequest; + +/** + * Controls the loading of reference objects for a query instance. + */ +public interface LoadContext { + + /** + * Return the minimum batch size when using QueryIterator with query joins. + */ + public int getSecondaryQueriesMinBatchSize(OrmQueryRequest parentRequest, int defaultQueryBatch); + + /** + * Execute any secondary (+query) queries if there are any defined. + * @param parentRequest the originating query request + */ + public void executeSecondaryQueries(OrmQueryRequest parentRequest); + + /** + * Register any secondary queries (+query or +lazy) with their + * appropriate LoadBeanContext or LoadManyContext. + *

+ * This is so the LoadBeanContext or LoadManyContext use the + * defined query for +query and +lazy execution. + *

+ */ + public void registerSecondaryQueries(SpiQuery query); + + /** + * Return the node for a given path which is used by autofetch profiling. + */ + public ObjectGraphNode getObjectGraphNode(String path); + + /** + * Return the persistence context used by this query and future lazy loading. + */ + public PersistenceContext getPersistenceContext(); + + /** + * Set the persistence context used by this query and future lazy loading. + *

+ * Used by query iterator when processing large result sets. + *

+ */ + public void resetPersistenceContext(PersistenceContext persistenceContext); + + /** + * Register a Bean for lazy loading. + */ + public void register(String path, EntityBeanIntercept ebi); + + /** + * Register a collection for lazy loading. + */ + public void register(String path, BeanCollection bc); + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java index 72ff7b107..4747778af 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java @@ -1,9 +1,9 @@ -package com.avaje.ebeaninternal.api; - - -/** - * Controls the loading of OneToMany and ManyToMany relationships. - */ -public interface LoadManyContext extends LoadSecondaryQuery { - -} +package com.avaje.ebeaninternal.api; + + +/** + * Controls the loading of OneToMany and ManyToMany relationships. + */ +public interface LoadManyContext extends LoadSecondaryQuery { + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java index 70d83eff7..9f4065f80 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -1,77 +1,77 @@ -package com.avaje.ebeaninternal.api; - -import java.util.List; - -import com.avaje.ebean.bean.BeanCollection; -import com.avaje.ebeaninternal.server.core.OrmQueryRequest; - -/** - * Request for loading Associated Many Beans. - */ -public class LoadManyRequest extends LoadRequest { - - private final List> batch; - - private final LoadManyBuffer loadContext; - - private final boolean onlyIds; - - private final boolean loadCache; - - public LoadManyRequest(LoadManyBuffer loadContext, boolean lazy, boolean onlyIds, boolean loadCache) { - this(loadContext, null, lazy, onlyIds, loadCache); - } - - public LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { - - super(parentRequest, lazy); - this.loadContext = loadContext; - this.batch = loadContext.getBatch(); - this.onlyIds = onlyIds; - this.loadCache = loadCache; - } - - public String getDescription() { - return "path:" + loadContext.getFullPath() + " size:" + batch.size(); - } - - /** - * Return the batch of collections to actually load. - */ - public List> getBatch() { - return batch; - } - - /** - * Return the load context. - */ - public LoadManyBuffer getLoadContext() { - return loadContext; - } - - /** - * Return true if lazy loading should only load the id values. - *

- * This for use when lazy loading is invoked on methods such as clear() and removeAll() where it - * generally makes sense to only fetch the Id values as the other property information is not - * used. - *

- */ - public boolean isOnlyIds() { - return onlyIds; - } - - /** - * Return true if we should load the Collection ids into the cache. - */ - public boolean isLoadCache() { - return loadCache; - } - - /** - * Return the batch size used for this load context. - */ - public int getBatchSize() { - return loadContext.getBatchSize(); - } -} +package com.avaje.ebeaninternal.api; + +import java.util.List; + +import com.avaje.ebean.bean.BeanCollection; +import com.avaje.ebeaninternal.server.core.OrmQueryRequest; + +/** + * Request for loading Associated Many Beans. + */ +public class LoadManyRequest extends LoadRequest { + + private final List> batch; + + private final LoadManyBuffer loadContext; + + private final boolean onlyIds; + + private final boolean loadCache; + + public LoadManyRequest(LoadManyBuffer loadContext, boolean lazy, boolean onlyIds, boolean loadCache) { + this(loadContext, null, lazy, onlyIds, loadCache); + } + + public LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { + + super(parentRequest, lazy); + this.loadContext = loadContext; + this.batch = loadContext.getBatch(); + this.onlyIds = onlyIds; + this.loadCache = loadCache; + } + + public String getDescription() { + return "path:" + loadContext.getFullPath() + " size:" + batch.size(); + } + + /** + * Return the batch of collections to actually load. + */ + public List> getBatch() { + return batch; + } + + /** + * Return the load context. + */ + public LoadManyBuffer getLoadContext() { + return loadContext; + } + + /** + * Return true if lazy loading should only load the id values. + *

+ * This for use when lazy loading is invoked on methods such as clear() and removeAll() where it + * generally makes sense to only fetch the Id values as the other property information is not + * used. + *

+ */ + public boolean isOnlyIds() { + return onlyIds; + } + + /** + * Return true if we should load the Collection ids into the cache. + */ + public boolean isLoadCache() { + return loadCache; + } + + /** + * Return the batch size used for this load context. + */ + public int getBatchSize() { + return loadContext.getBatchSize(); + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java index 0da6a26d9..d5ed56b7a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java @@ -1,51 +1,51 @@ -package com.avaje.ebeaninternal.api; - -import com.avaje.ebean.Transaction; -import com.avaje.ebeaninternal.server.core.OrmQueryRequest; - -/** - * Request for loading Associated One Beans. - */ -public abstract class LoadRequest { - - protected final OrmQueryRequest parentRequest; - - protected final Transaction transaction; - - protected final boolean lazy; - - public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { - - this.parentRequest = parentRequest; - this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); - this.lazy = lazy; - } - - /** - * Log the just executed secondary query with the 'root' query if 'logSecondaryQuery' is set to - * true. This is for testing purposes to confirm the secondary query executes etc. - */ - public void logSecondaryQuery(SpiQuery query) { - if (parentRequest != null && parentRequest.isLogSecondaryQuery()) { - parentRequest.getQuery().logSecondaryQuery(query); - } - } - - /** - * Return true if this is a lazy load and false if it is a secondary query. - */ - public boolean isLazy() { - return lazy; - } - - /** - * Return the transaction to use if this is a secondary query. - *

- * Lazy loading queries run in their own transaction. - *

- */ - public Transaction getTransaction() { - return transaction; - } - -} +package com.avaje.ebeaninternal.api; + +import com.avaje.ebean.Transaction; +import com.avaje.ebeaninternal.server.core.OrmQueryRequest; + +/** + * Request for loading Associated One Beans. + */ +public abstract class LoadRequest { + + protected final OrmQueryRequest parentRequest; + + protected final Transaction transaction; + + protected final boolean lazy; + + public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { + + this.parentRequest = parentRequest; + this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); + this.lazy = lazy; + } + + /** + * Log the just executed secondary query with the 'root' query if 'logSecondaryQuery' is set to + * true. This is for testing purposes to confirm the secondary query executes etc. + */ + public void logSecondaryQuery(SpiQuery query) { + if (parentRequest != null && parentRequest.isLogSecondaryQuery()) { + parentRequest.getQuery().logSecondaryQuery(query); + } + } + + /** + * Return true if this is a lazy load and false if it is a secondary query. + */ + public boolean isLazy() { + return lazy; + } + + /** + * Return the transaction to use if this is a secondary query. + *

+ * Lazy loading queries run in their own transaction. + *

+ */ + public Transaction getTransaction() { + return transaction; + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java index 23a90dcc5..147ede69a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java @@ -1,18 +1,18 @@ -package com.avaje.ebeaninternal.api; - -import com.avaje.ebeaninternal.server.core.OrmQueryRequest; - -/** - * Defines the method for executing secondary queries. - *

- * That is +query nodes in a orm query get executed after - * the initial query as 'secondary' queries. - *

- */ -public interface LoadSecondaryQuery { - - /** - * Execute the secondary query with a given batch size. - */ - public void loadSecondaryQuery(OrmQueryRequest parentRequest); -} +package com.avaje.ebeaninternal.api; + +import com.avaje.ebeaninternal.server.core.OrmQueryRequest; + +/** + * Defines the method for executing secondary queries. + *

+ * That is +query nodes in a orm query get executed after + * the initial query as 'secondary' queries. + *

+ */ +public interface LoadSecondaryQuery { + + /** + * Execute the secondary query with a given batch size. + */ + public void loadSecondaryQuery(OrmQueryRequest parentRequest); +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java b/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java index bdc3208d3..b7905b1e5 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ManyWhereJoins.java @@ -1,153 +1,153 @@ -package com.avaje.ebeaninternal.api; - -import java.io.Serializable; -import java.util.Collection; -import java.util.TreeMap; -import java.util.TreeSet; - -import com.avaje.ebeaninternal.server.deploy.BeanProperty; -import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; -import com.avaje.ebeaninternal.server.el.ElPropertyDeploy; -import com.avaje.ebeaninternal.server.query.SplitName; -import com.avaje.ebeaninternal.server.query.SqlJoinType; - -/** - * Holds the joins needs to support the many where predicates. - * These joins are independent of any 'fetch' joins on the many. - */ -public class ManyWhereJoins implements Serializable { - - private static final long serialVersionUID = -6490181101871795417L; - - private final TreeMap joins = new TreeMap(); - - private StringBuilder formulaProperties = new StringBuilder(); - - private boolean formulaWithJoin; - - /** - * 'Mode' indicating that joins added while this is true are required to be outer joins. - */ - private boolean requireOuterJoins; - - /** - * Return the current 'mode' indicating if outer joins are currently required or not. - */ - public boolean isRequireOuterJoins() { - return requireOuterJoins; - } - - /** - * Set the 'mode' to be that joins added are required to be outer joins. - * This is set during the evaluation of disjunction predicates. - */ - public void setRequireOuterJoins(boolean requireOuterJoins) { - this.requireOuterJoins = requireOuterJoins; - } - - /** - * Add a many where join. - */ - public void add(ElPropertyDeploy elProp) { - - String join = elProp.getElPrefix(); - BeanProperty p = elProp.getBeanProperty(); - if (p instanceof BeanPropertyAssocMany){ - join = addManyToJoin(join, p.getName()); - } - if (join != null){ - addJoin(join); - if (p != null) { - String secondaryTableJoinPrefix = p.getSecondaryTableJoinPrefix(); - if (secondaryTableJoinPrefix != null) { - addJoin(join+"."+secondaryTableJoinPrefix); - } - } - addParentJoins(join); - } - } - - /** - * For 'many' properties we also need to add the name of the - * many property to get the full logical name of the join. - */ - private String addManyToJoin(String join, String manyPropName){ - if (join == null){ - return manyPropName; - } else { - return join+"."+manyPropName; - } - } - - private void addParentJoins(String join) { - String[] split = SplitName.split(join); - if (split[0] != null){ - addJoin(split[0]); - addParentJoins(split[0]); - } - } - - private void addJoin(String property) { - SqlJoinType joinType = (requireOuterJoins) ? SqlJoinType.OUTER: SqlJoinType.INNER; - joins.put(property, new PropertyJoin(property, joinType)); - } - - /** - * Return true if there are no extra many where joins. - */ - public boolean isEmpty() { - return joins.isEmpty(); - } - - /** - * Return the set of many where joins. - */ - public Collection getPropertyJoins() { - return joins.values(); - } - - /** - * Return the set of property names for the many where joins. - */ - public TreeSet getPropertyNames() { - - TreeSet propertyNames = new TreeSet(); - for (PropertyJoin join : joins.values()) { - propertyNames.add(join.getProperty()); - } - return propertyNames; - } - - /** - * In findRowCount query found a formula property with a join clause so building a select clause - * specifically for the findRowCount query. - */ - public void addFormulaWithJoin(String propertyName) { - if (formulaWithJoin) { - formulaProperties.append(","); - } else { - formulaProperties = new StringBuilder(); - formulaWithJoin = true; - } - formulaProperties.append(propertyName); - } - - public boolean isHasMany() { - return formulaWithJoin || !joins.isEmpty(); - } - - /** - * Return true if the findRowCount query just needs the id property in the select clause. - */ - public boolean isSelectId() { - return !formulaWithJoin; - } - - /** - * Return the formula properties to build the select clause for a findRowCount query. - */ - public String getFormulaProperties() { - return formulaProperties.toString(); - } - -} +package com.avaje.ebeaninternal.api; + +import java.io.Serializable; +import java.util.Collection; +import java.util.TreeMap; +import java.util.TreeSet; + +import com.avaje.ebeaninternal.server.deploy.BeanProperty; +import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; +import com.avaje.ebeaninternal.server.el.ElPropertyDeploy; +import com.avaje.ebeaninternal.server.query.SplitName; +import com.avaje.ebeaninternal.server.query.SqlJoinType; + +/** + * Holds the joins needs to support the many where predicates. + * These joins are independent of any 'fetch' joins on the many. + */ +public class ManyWhereJoins implements Serializable { + + private static final long serialVersionUID = -6490181101871795417L; + + private final TreeMap joins = new TreeMap(); + + private StringBuilder formulaProperties = new StringBuilder(); + + private boolean formulaWithJoin; + + /** + * 'Mode' indicating that joins added while this is true are required to be outer joins. + */ + private boolean requireOuterJoins; + + /** + * Return the current 'mode' indicating if outer joins are currently required or not. + */ + public boolean isRequireOuterJoins() { + return requireOuterJoins; + } + + /** + * Set the 'mode' to be that joins added are required to be outer joins. + * This is set during the evaluation of disjunction predicates. + */ + public void setRequireOuterJoins(boolean requireOuterJoins) { + this.requireOuterJoins = requireOuterJoins; + } + + /** + * Add a many where join. + */ + public void add(ElPropertyDeploy elProp) { + + String join = elProp.getElPrefix(); + BeanProperty p = elProp.getBeanProperty(); + if (p instanceof BeanPropertyAssocMany){ + join = addManyToJoin(join, p.getName()); + } + if (join != null){ + addJoin(join); + if (p != null) { + String secondaryTableJoinPrefix = p.getSecondaryTableJoinPrefix(); + if (secondaryTableJoinPrefix != null) { + addJoin(join+"."+secondaryTableJoinPrefix); + } + } + addParentJoins(join); + } + } + + /** + * For 'many' properties we also need to add the name of the + * many property to get the full logical name of the join. + */ + private String addManyToJoin(String join, String manyPropName){ + if (join == null){ + return manyPropName; + } else { + return join+"."+manyPropName; + } + } + + private void addParentJoins(String join) { + String[] split = SplitName.split(join); + if (split[0] != null){ + addJoin(split[0]); + addParentJoins(split[0]); + } + } + + private void addJoin(String property) { + SqlJoinType joinType = (requireOuterJoins) ? SqlJoinType.OUTER: SqlJoinType.INNER; + joins.put(property, new PropertyJoin(property, joinType)); + } + + /** + * Return true if there are no extra many where joins. + */ + public boolean isEmpty() { + return joins.isEmpty(); + } + + /** + * Return the set of many where joins. + */ + public Collection getPropertyJoins() { + return joins.values(); + } + + /** + * Return the set of property names for the many where joins. + */ + public TreeSet getPropertyNames() { + + TreeSet propertyNames = new TreeSet(); + for (PropertyJoin join : joins.values()) { + propertyNames.add(join.getProperty()); + } + return propertyNames; + } + + /** + * In findRowCount query found a formula property with a join clause so building a select clause + * specifically for the findRowCount query. + */ + public void addFormulaWithJoin(String propertyName) { + if (formulaWithJoin) { + formulaProperties.append(","); + } else { + formulaProperties = new StringBuilder(); + formulaWithJoin = true; + } + formulaProperties.append(propertyName); + } + + public boolean isHasMany() { + return formulaWithJoin || !joins.isEmpty(); + } + + /** + * Return true if the findRowCount query just needs the id property in the select clause. + */ + public boolean isSelectId() { + return !formulaWithJoin; + } + + /** + * Return the formula properties to build the select clause for a findRowCount query. + */ + public String getFormulaProperties() { + return formulaProperties.toString(); + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java index ea9a8454d..3a2e8221c 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java @@ -1,12 +1,12 @@ -package com.avaje.ebeaninternal.api; - -import java.io.Serializable; - -/** - * Object used as a synchronization monitor that is serializable. - */ -public class Monitor implements Serializable { - - private static final long serialVersionUID = -2741687226680981940L; - -} +package com.avaje.ebeaninternal.api; + +import java.io.Serializable; + +/** + * Object used as a synchronization monitor that is serializable. + */ +public class Monitor implements Serializable { + + private static final long serialVersionUID = -2741687226680981940L; + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java index 462eac317..46ee68aa5 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopeTrans.java @@ -1,236 +1,236 @@ -package com.avaje.ebeaninternal.api; - -import java.util.ArrayList; - -import com.avaje.ebean.TxScope; -import com.avaje.ebean.config.PersistBatch; - -/** - * Used internally to handle the scoping of transactions for methods. - */ -public class ScopeTrans implements Thread.UncaughtExceptionHandler { - - private static final int OPCODE_ATHROW = 191; - - private final SpiTransactionScopeManager scopeMgr; - - /** - * The suspended transaction (can be null). - */ - private final SpiTransaction suspendedTransaction; - - /** - * The transaction in scope (can be null). - */ - private final SpiTransaction transaction; - - /** - * If true by default rollback on Checked exceptions. - */ - private final boolean rollbackOnChecked; - - /** - * True if the transaction was created and hence should be committed - * on finally if it hasn't already been rolled back. - */ - private final boolean created; - - /** - * Explicit set of Exceptions that DO NOT cause a rollback to occur. - */ - private final ArrayList> noRollbackFor; - - /** - * Explicit set of Exceptions that DO cause a rollback to occur. - */ - private final ArrayList> rollbackFor; - - private PersistBatch restoreBatch; - - private PersistBatch restoreBatchOnCascade; - - private int restoreBatchSize; - - /** - * Flag set when a rollback has occurred. - */ - private boolean rolledBack; - - - public ScopeTrans(boolean rollbackOnChecked, boolean created, SpiTransaction transaction, TxScope txScope, - SpiTransaction suspendedTransaction, SpiTransactionScopeManager scopeMgr) { - - this.rollbackOnChecked = rollbackOnChecked; - this.created = created; - this.transaction = transaction; - this.suspendedTransaction = suspendedTransaction; - this.scopeMgr = scopeMgr; - - this.noRollbackFor = txScope.getNoRollbackFor(); - this.rollbackFor = txScope.getRollbackFor(); - - if (transaction != null) { - if (!created && txScope.isBatchSet() || txScope.isBatchOnCascadeSet() || txScope.isBatchSizeSet()) { - restoreBatch = transaction.getBatch(); - restoreBatchOnCascade = transaction.getBatchOnCascade(); - restoreBatchSize = transaction.getBatchSize(); - } - if (txScope.isBatchSet()) { - transaction.setBatch(txScope.getBatch()); - } - if (txScope.isBatchOnCascadeSet()) { - transaction.setBatchOnCascade(txScope.getBatchOnCascade()); - } - if (txScope.isBatchSizeSet()) { - transaction.setBatchSize(txScope.getBatchSize()); - } - } - - } - - /** - * Return the current/active transaction. - */ - protected SpiTransaction getTransaction() { - return transaction; - } - - /** - * Called when the Thread catches any uncaught exception. - * For example, an unexpected NullPointerException or Error. - */ - public void uncaughtException(Thread thread, Throwable e) { - - // rollback transaction if required - caughtThrowable(e); - - // reinstate suspended transaction - onFinally(); - } - - /** - * Returned via RETURN or expected Exception from the method. - * @param returnOrThrowable the return value or Throwable - * @param opCode indicates - */ - public void onExit(Object returnOrThrowable, int opCode) { - - if (opCode == OPCODE_ATHROW){ - // exited with a Throwable - caughtThrowable((Throwable)returnOrThrowable); - } - onFinally(); - } - - - /** - * Commit if the transaction exists and has not already been rolled back. - * Also reinstate the suspended transaction if there was one. - */ - public void onFinally() { - - try { - if (!rolledBack) { - commitTransaction(); - } - } finally { - restoreSuspended(); - } - } - - protected void restoreSuspended() { - if (suspendedTransaction != null){ - // put the previously suspended transaction - // back onto the ThreadLocal or equivalent - scopeMgr.replace(suspendedTransaction); - } - } - - protected void commitTransaction() { - if (created) { - transaction.commit(); - } else { - if (restoreBatch != null) { - transaction.setBatch(restoreBatch); - } - if (restoreBatchOnCascade != null) { - transaction.setBatchOnCascade(restoreBatchOnCascade); - } - if (restoreBatchSize > 0) { - transaction.setBatchSize(restoreBatchSize); - } - } - } - - /** - * An Error was caught and this ALWAYS causes a rollback to occur. - * Returns the error and this should be thrown by the calling code. - */ - public Error caughtError(Error e) { - rollback(e); - return e; - } - - /** - * An Exception was caught and may or may not cause a rollback to occur. - * Returns the exception and this should be thrown by the calling code. - */ - public T caughtThrowable(T e) { - - if (isRollbackThrowable(e)) { - rollback(e); - } - return e; - } - - protected void rollback(Throwable e) { - if (transaction != null && transaction.isActive()) { - // transaction is null for NOT_SUPPORTED and sometimes SUPPORTS - // and Inactive (already rolled back) if nested REQUIRED - transaction.rollback(e); - } - rolledBack = true; - } - - /** - * Return true if this throwable should cause a rollback to occur. - */ - private boolean isRollbackThrowable(Throwable e) { - - if (e instanceof Error){ - return true; - } - - if (noRollbackFor != null){ - for (int i = 0; i < noRollbackFor.size(); i++) { - if (noRollbackFor.get(i).equals(e.getClass())) { - - // explicit no rollback for this one - return false; - } - } - } - - if (rollbackFor != null){ - for (int i = 0; i < rollbackFor.size(); i++) { - if (rollbackFor.get(i).equals(e.getClass())) { - // explicit rollback for this one - return true; - } - } - } - - - if (e instanceof RuntimeException) { - return true; - - } else { - // checked exceptions... - // EJB defaults this to false which is not intuitive IMO - // Ebean makes this configurable (default to true) - return rollbackOnChecked; - } - } - - -} +package com.avaje.ebeaninternal.api; + +import java.util.ArrayList; + +import com.avaje.ebean.TxScope; +import com.avaje.ebean.config.PersistBatch; + +/** + * Used internally to handle the scoping of transactions for methods. + */ +public class ScopeTrans implements Thread.UncaughtExceptionHandler { + + private static final int OPCODE_ATHROW = 191; + + private final SpiTransactionScopeManager scopeMgr; + + /** + * The suspended transaction (can be null). + */ + private final SpiTransaction suspendedTransaction; + + /** + * The transaction in scope (can be null). + */ + private final SpiTransaction transaction; + + /** + * If true by default rollback on Checked exceptions. + */ + private final boolean rollbackOnChecked; + + /** + * True if the transaction was created and hence should be committed + * on finally if it hasn't already been rolled back. + */ + private final boolean created; + + /** + * Explicit set of Exceptions that DO NOT cause a rollback to occur. + */ + private final ArrayList> noRollbackFor; + + /** + * Explicit set of Exceptions that DO cause a rollback to occur. + */ + private final ArrayList> rollbackFor; + + private PersistBatch restoreBatch; + + private PersistBatch restoreBatchOnCascade; + + private int restoreBatchSize; + + /** + * Flag set when a rollback has occurred. + */ + private boolean rolledBack; + + + public ScopeTrans(boolean rollbackOnChecked, boolean created, SpiTransaction transaction, TxScope txScope, + SpiTransaction suspendedTransaction, SpiTransactionScopeManager scopeMgr) { + + this.rollbackOnChecked = rollbackOnChecked; + this.created = created; + this.transaction = transaction; + this.suspendedTransaction = suspendedTransaction; + this.scopeMgr = scopeMgr; + + this.noRollbackFor = txScope.getNoRollbackFor(); + this.rollbackFor = txScope.getRollbackFor(); + + if (transaction != null) { + if (!created && txScope.isBatchSet() || txScope.isBatchOnCascadeSet() || txScope.isBatchSizeSet()) { + restoreBatch = transaction.getBatch(); + restoreBatchOnCascade = transaction.getBatchOnCascade(); + restoreBatchSize = transaction.getBatchSize(); + } + if (txScope.isBatchSet()) { + transaction.setBatch(txScope.getBatch()); + } + if (txScope.isBatchOnCascadeSet()) { + transaction.setBatchOnCascade(txScope.getBatchOnCascade()); + } + if (txScope.isBatchSizeSet()) { + transaction.setBatchSize(txScope.getBatchSize()); + } + } + + } + + /** + * Return the current/active transaction. + */ + protected SpiTransaction getTransaction() { + return transaction; + } + + /** + * Called when the Thread catches any uncaught exception. + * For example, an unexpected NullPointerException or Error. + */ + public void uncaughtException(Thread thread, Throwable e) { + + // rollback transaction if required + caughtThrowable(e); + + // reinstate suspended transaction + onFinally(); + } + + /** + * Returned via RETURN or expected Exception from the method. + * @param returnOrThrowable the return value or Throwable + * @param opCode indicates + */ + public void onExit(Object returnOrThrowable, int opCode) { + + if (opCode == OPCODE_ATHROW){ + // exited with a Throwable + caughtThrowable((Throwable)returnOrThrowable); + } + onFinally(); + } + + + /** + * Commit if the transaction exists and has not already been rolled back. + * Also reinstate the suspended transaction if there was one. + */ + public void onFinally() { + + try { + if (!rolledBack) { + commitTransaction(); + } + } finally { + restoreSuspended(); + } + } + + protected void restoreSuspended() { + if (suspendedTransaction != null){ + // put the previously suspended transaction + // back onto the ThreadLocal or equivalent + scopeMgr.replace(suspendedTransaction); + } + } + + protected void commitTransaction() { + if (created) { + transaction.commit(); + } else { + if (restoreBatch != null) { + transaction.setBatch(restoreBatch); + } + if (restoreBatchOnCascade != null) { + transaction.setBatchOnCascade(restoreBatchOnCascade); + } + if (restoreBatchSize > 0) { + transaction.setBatchSize(restoreBatchSize); + } + } + } + + /** + * An Error was caught and this ALWAYS causes a rollback to occur. + * Returns the error and this should be thrown by the calling code. + */ + public Error caughtError(Error e) { + rollback(e); + return e; + } + + /** + * An Exception was caught and may or may not cause a rollback to occur. + * Returns the exception and this should be thrown by the calling code. + */ + public T caughtThrowable(T e) { + + if (isRollbackThrowable(e)) { + rollback(e); + } + return e; + } + + protected void rollback(Throwable e) { + if (transaction != null && transaction.isActive()) { + // transaction is null for NOT_SUPPORTED and sometimes SUPPORTS + // and Inactive (already rolled back) if nested REQUIRED + transaction.rollback(e); + } + rolledBack = true; + } + + /** + * Return true if this throwable should cause a rollback to occur. + */ + private boolean isRollbackThrowable(Throwable e) { + + if (e instanceof Error){ + return true; + } + + if (noRollbackFor != null){ + for (int i = 0; i < noRollbackFor.size(); i++) { + if (noRollbackFor.get(i).equals(e.getClass())) { + + // explicit no rollback for this one + return false; + } + } + } + + if (rollbackFor != null){ + for (int i = 0; i < rollbackFor.size(); i++) { + if (rollbackFor.get(i).equals(e.getClass())) { + // explicit rollback for this one + return true; + } + } + } + + + if (e instanceof RuntimeException) { + return true; + + } else { + // checked exceptions... + // EJB defaults this to false which is not intuitive IMO + // Ebean makes this configurable (default to true) + return rollbackOnChecked; + } + } + + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java index 2feea537a..1cdfd6cfe 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java @@ -1,198 +1,198 @@ -package com.avaje.ebeaninternal.api; - -import java.util.List; - -import com.avaje.ebean.*; -import com.avaje.ebean.bean.BeanCollectionLoader; -import com.avaje.ebean.bean.BeanLoader; -import com.avaje.ebean.bean.CallStack; -import com.avaje.ebean.bean.ObjectGraphNode; -import com.avaje.ebean.config.ServerConfig; -import com.avaje.ebean.config.dbplatform.DatabasePlatform; -import com.avaje.ebeaninternal.server.autofetch.AutoFetchManager; -import com.avaje.ebeaninternal.server.core.PstmtBatch; -import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest; -import com.avaje.ebeaninternal.server.ddl.DdlGenerator; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; -import com.avaje.ebeaninternal.server.query.CQuery; -import com.avaje.ebeaninternal.server.query.CQueryEngine; -import com.avaje.ebeaninternal.server.transaction.RemoteTransactionEvent; - -/** - * Service Provider extension to EbeanServer. - */ -public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionLoader { - - /** - * For internal use, shutdown of the server invoked by JVM Shutdown. - */ - public void shutdownManaged(); - - /** - * Return true if query origins should be collected. - */ - public boolean isCollectQueryOrigins(); - - /** - * Return the server configuration. - */ - public ServerConfig getServerConfig(); - - /** - * Return the DatabasePlatform for this server. - */ - public DatabasePlatform getDatabasePlatform(); - - /** - * Return a JDBC driver specific handler for batching. - *

- * Required for Oracle specific batch handling. - *

- */ - public PstmtBatch getPstmtBatch(); - - /** - * Create an object to represent the current CallStack. - *

- * Typically used to identify the origin of queries for Autofetch and object - * graph costing. - *

- */ - public CallStack createCallStack(); - - /** - * Return the PersistenceContextScope to use defined at query or server level. - */ - public PersistenceContextScope getPersistenceContextScope(SpiQuery query); - - /** - * Return the DDL generator. - */ - public DdlGenerator getDdlGenerator(); - - /** - * Return the AutoFetchListener. - */ - public AutoFetchManager getAutoFetchManager(); - - /** - * Clear the query execution statistics. - */ - public void clearQueryStatistics(); - - /** - * Return all the descriptors. - */ - public List> getBeanDescriptors(); - - /** - * Return the BeanDescriptor for a given type of bean. - */ - public BeanDescriptor getBeanDescriptor(Class type); - - /** - * Return BeanDescriptor using it's unique id. - */ - public BeanDescriptor getBeanDescriptorById(String descriptorId); - - /** - * Return BeanDescriptors mapped to this table. - */ - public List> getBeanDescriptors(String tableName); - - /** - * Process committed changes from another framework. - *

- * This notifies this instance of the framework that beans have been committed - * externally to it. Either by another framework or clustered server. It uses - * this to maintain its cache and text indexes appropriately. - *

- */ - public void externalModification(TransactionEventTable event); - - /** - * Create a ServerTransaction. - *

- * To specify to use the default transaction isolation use a value of -1. - *

- */ - public SpiTransaction createServerTransaction(boolean isExplicit, int isolationLevel); - - /** - * Return the current transaction or null if there is no current transaction. - */ - public SpiTransaction getCurrentServerTransaction(); - - /** - * Create a ScopeTrans for a method for the given scope definition. - */ - public ScopeTrans createScopeTrans(TxScope txScope); - - /** - * Create a ServerTransaction for query purposes. - */ - public SpiTransaction createQueryTransaction(); - - /** - * An event from another server in the cluster used to notify local - * BeanListeners of remote inserts updates and deletes. - */ - public void remoteTransactionEvent(RemoteTransactionEvent event); - - /** - * Create a query request object. - */ - public SpiOrmQueryRequest createQueryRequest(BeanDescriptor desc, SpiQuery q, - Transaction t); - - /** - * Compile a query. - */ - public CQuery compileQuery(Query query, Transaction t); - - /** - * Return the queryEngine for this server. - */ - public CQueryEngine getQueryEngine(); - - /** - * Execute the findId's query but without copying the query. - *

- * Used so that the list of Id's can be made accessible to client code before - * the query has finished (if executing in a background thread). - *

- */ - public List findIdsWithCopy(Query query, Transaction t); - - /** - * Execute the findRowCount query but without copying the query. - */ - public int findRowCountWithCopy(Query query, Transaction t); - - /** - * Load a batch of Associated One Beans. - */ - public void loadBean(LoadBeanRequest loadRequest); - - /** - * Lazy load a batch of Many's. - */ - public void loadMany(LoadManyRequest loadRequest); - - /** - * Return the default batch size for lazy loading. - */ - public int getLazyLoadBatchSize(); - - /** - * Return true if the type is known as an Entity or Xml type or a List Set or - * Map of known bean types. - */ - public boolean isSupportedType(java.lang.reflect.Type genericType); - - /** - * Collect query statistics by ObjectGraphNode. Used for Lazy loading reporting. - */ - public void collectQueryStats(ObjectGraphNode objectGraphNode, long loadedBeanCount, long timeMicros); - -} +package com.avaje.ebeaninternal.api; + +import java.util.List; + +import com.avaje.ebean.*; +import com.avaje.ebean.bean.BeanCollectionLoader; +import com.avaje.ebean.bean.BeanLoader; +import com.avaje.ebean.bean.CallStack; +import com.avaje.ebean.bean.ObjectGraphNode; +import com.avaje.ebean.config.ServerConfig; +import com.avaje.ebean.config.dbplatform.DatabasePlatform; +import com.avaje.ebeaninternal.server.autofetch.AutoFetchManager; +import com.avaje.ebeaninternal.server.core.PstmtBatch; +import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest; +import com.avaje.ebeaninternal.server.ddl.DdlGenerator; +import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeaninternal.server.query.CQuery; +import com.avaje.ebeaninternal.server.query.CQueryEngine; +import com.avaje.ebeaninternal.server.transaction.RemoteTransactionEvent; + +/** + * Service Provider extension to EbeanServer. + */ +public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionLoader { + + /** + * For internal use, shutdown of the server invoked by JVM Shutdown. + */ + public void shutdownManaged(); + + /** + * Return true if query origins should be collected. + */ + public boolean isCollectQueryOrigins(); + + /** + * Return the server configuration. + */ + public ServerConfig getServerConfig(); + + /** + * Return the DatabasePlatform for this server. + */ + public DatabasePlatform getDatabasePlatform(); + + /** + * Return a JDBC driver specific handler for batching. + *

+ * Required for Oracle specific batch handling. + *

+ */ + public PstmtBatch getPstmtBatch(); + + /** + * Create an object to represent the current CallStack. + *

+ * Typically used to identify the origin of queries for Autofetch and object + * graph costing. + *

+ */ + public CallStack createCallStack(); + + /** + * Return the PersistenceContextScope to use defined at query or server level. + */ + public PersistenceContextScope getPersistenceContextScope(SpiQuery query); + + /** + * Return the DDL generator. + */ + public DdlGenerator getDdlGenerator(); + + /** + * Return the AutoFetchListener. + */ + public AutoFetchManager getAutoFetchManager(); + + /** + * Clear the query execution statistics. + */ + public void clearQueryStatistics(); + + /** + * Return all the descriptors. + */ + public List> getBeanDescriptors(); + + /** + * Return the BeanDescriptor for a given type of bean. + */ + public BeanDescriptor getBeanDescriptor(Class type); + + /** + * Return BeanDescriptor using it's unique id. + */ + public BeanDescriptor getBeanDescriptorById(String descriptorId); + + /** + * Return BeanDescriptors mapped to this table. + */ + public List> getBeanDescriptors(String tableName); + + /** + * Process committed changes from another framework. + *

+ * This notifies this instance of the framework that beans have been committed + * externally to it. Either by another framework or clustered server. It uses + * this to maintain its cache and text indexes appropriately. + *

+ */ + public void externalModification(TransactionEventTable event); + + /** + * Create a ServerTransaction. + *

+ * To specify to use the default transaction isolation use a value of -1. + *

+ */ + public SpiTransaction createServerTransaction(boolean isExplicit, int isolationLevel); + + /** + * Return the current transaction or null if there is no current transaction. + */ + public SpiTransaction getCurrentServerTransaction(); + + /** + * Create a ScopeTrans for a method for the given scope definition. + */ + public ScopeTrans createScopeTrans(TxScope txScope); + + /** + * Create a ServerTransaction for query purposes. + */ + public SpiTransaction createQueryTransaction(); + + /** + * An event from another server in the cluster used to notify local + * BeanListeners of remote inserts updates and deletes. + */ + public void remoteTransactionEvent(RemoteTransactionEvent event); + + /** + * Create a query request object. + */ + public SpiOrmQueryRequest createQueryRequest(BeanDescriptor desc, SpiQuery q, + Transaction t); + + /** + * Compile a query. + */ + public CQuery compileQuery(Query query, Transaction t); + + /** + * Return the queryEngine for this server. + */ + public CQueryEngine getQueryEngine(); + + /** + * Execute the findId's query but without copying the query. + *

+ * Used so that the list of Id's can be made accessible to client code before + * the query has finished (if executing in a background thread). + *

+ */ + public List findIdsWithCopy(Query query, Transaction t); + + /** + * Execute the findRowCount query but without copying the query. + */ + public int findRowCountWithCopy(Query query, Transaction t); + + /** + * Load a batch of Associated One Beans. + */ + public void loadBean(LoadBeanRequest loadRequest); + + /** + * Lazy load a batch of Many's. + */ + public void loadMany(LoadManyRequest loadRequest); + + /** + * Return the default batch size for lazy loading. + */ + public int getLazyLoadBatchSize(); + + /** + * Return true if the type is known as an Entity or Xml type or a List Set or + * Map of known bean types. + */ + public boolean isSupportedType(java.lang.reflect.Type genericType); + + /** + * Collect query statistics by ObjectGraphNode. Used for Lazy loading reporting. + */ + public void collectQueryStats(ObjectGraphNode objectGraphNode, long loadedBeanCount, long timeMicros); + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionFactory.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionFactory.java index 68dcae25c..3592598ba 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionFactory.java @@ -1,12 +1,12 @@ -package com.avaje.ebeaninternal.api; - -import com.avaje.ebean.ExpressionFactory; - -public interface SpiExpressionFactory extends ExpressionFactory { - - /** - * Create another expression factory with a given sub path. - */ - public ExpressionFactory createExpressionFactory(); - -} +package com.avaje.ebeaninternal.api; + +import com.avaje.ebean.ExpressionFactory; + +public interface SpiExpressionFactory extends ExpressionFactory { + + /** + * Create another expression factory with a given sub path. + */ + public ExpressionFactory createExpressionFactory(); + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java index 7ae485ee6..e6f7438bc 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiQuery.java @@ -1,619 +1,619 @@ -package com.avaje.ebeaninternal.api; - -import java.util.ArrayList; -import java.util.List; - -import com.avaje.ebean.ExpressionList; -import com.avaje.ebean.OrderBy; -import com.avaje.ebean.PersistenceContextScope; -import com.avaje.ebean.Query; -import com.avaje.ebean.bean.BeanCollectionTouched; -import com.avaje.ebean.bean.CallStack; -import com.avaje.ebean.bean.EntityBean; -import com.avaje.ebean.bean.ObjectGraphNode; -import com.avaje.ebean.bean.PersistenceContext; -import com.avaje.ebean.event.BeanQueryRequest; -import com.avaje.ebeaninternal.server.autofetch.AutoFetchManager; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; -import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; -import com.avaje.ebeaninternal.server.deploy.TableJoin; -import com.avaje.ebeaninternal.server.query.CancelableQuery; -import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; -import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail; -import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties; - -/** - * Object Relational query - Internal extension to Query object. - */ -public interface SpiQuery extends Query { - - public enum Mode { - NORMAL(false), LAZYLOAD_MANY(false), LAZYLOAD_BEAN(true), REFRESH_BEAN(true); - Mode(boolean loadContextBean) { - this.loadContextBean = loadContextBean; - } - - private final boolean loadContextBean; - - public boolean isLoadContextBean() { - return loadContextBean; - } - } - - /** - * The type of query result. - */ - public enum Type { - - /** - * Find by Id or unique returning a single bean. - */ - BEAN, - - /** - * Find returning a List. - */ - LIST, - - /** - * Find returning a Set. - */ - SET, - - /** - * Find returning a Map. - */ - MAP, - - /** - * Find the Id's. - */ - ID_LIST, - - /** - * Find rowCount. - */ - ROWCOUNT, - - /** - * A subquery used as part of a where clause. - */ - SUBQUERY - } - - /** - * Return the PersistenceContextScope that this query should use. - *

- * This can be null and in that case use the default scope. - *

- */ - public PersistenceContextScope getPersistenceContextScope(); - - /** - * Return the default lazy load batch size. - */ - public int getLazyLoadBatchSize(); - - /** - * Return true if select all properties was used to ensure the property - * invoking a lazy load was included in the query. - */ - public boolean selectAllForLazyLoadProperty(); - - /** - * Set the query mode. - */ - public void setMode(Mode m); - - /** - * Return the query mode. - */ - public Mode getMode(); - - /** - * Return a listener that wants to be notified when the bean collection is - * first used. - */ - public BeanCollectionTouched getBeanCollectionTouched(); - - /** - * Set a listener to be notified when the bean collection has been touched - * (when the list/set/map is first used). - */ - public void setBeanCollectionTouched(BeanCollectionTouched notify); - - /** - * Set the list of Id's that is being populated. - *

- * This is a mutating list of id's and we are setting this so that other - * threads have access to the id's before the id query has finished. - *

- */ - public void setIdList(List ids); - - /** - * Return the list of Id's that is currently being fetched by a background - * thread. - */ - public List getIdList(); - - /** - * Return a copy of the query. - */ - public SpiQuery copy(); - - /** - * Return the type of query (List, Set, Map, Bean, rowCount etc). - */ - public Type getType(); - - /** - * Set the query type (List, Set etc). - */ - public void setType(Type type); - - /** - * Return a more detailed description of the lazy or query load. - */ - public String getLoadDescription(); - - /** - * Return the load mode (+lazy or +query). - */ - public String getLoadMode(); - - /** - * This becomes a lazy loading query for a many relationship. - */ - public void setLazyLoadForParents(List parentIds, BeanPropertyAssocMany many); - - /** - * Return the lazy loading 'many' property. - */ - public BeanPropertyAssocMany getLazyLoadForParentsProperty(); - - /** - * Return the list of parent Id's for lazy loading. - */ - public List getLazyLoadForParentIds(); - - /** - * Set the load mode (+lazy or +query) and the load description. - */ - public void setLoadDescription(String loadMode, String loadDescription); - - /** - * Set the BeanDescriptor for the root type of this query. - */ - public void setBeanDescriptor(BeanDescriptor desc); - - /** - * Initialise/determine the joins required to support 'many' where clause predicates. - */ - public boolean initManyWhereJoins(); - - /** - * Return the joins required to support predicates on the many properties. - */ - public ManyWhereJoins getManyWhereJoins(); - - /** - * Convert this natural key query into a find by id query. - */ - public void convertWhereNaturalKeyToId(Object idValue); - - /** - * Return a Natural Key bind parameter if supported by this query. - */ - public NaturalKeyBindParam getNaturalKeyBindParam(); - - /** - * Set the query to select the id property only. - */ - public void setSelectId(); - - /** - * Set a filter to a join path. - */ - public void setFilterMany(String prop, ExpressionList filterMany); - - /** - * Remove the query joins from query detail. - *

- * These are registered with the Load Context. - *

- */ - public List removeQueryJoins(); - - /** - * Remove the lazy joins from query detail. - *

- * These are registered with the Load Context. - *

- */ - public List removeLazyJoins(); - - /** - * Set the path of the many when +query/+lazy loading query is executed. - */ - public void setLazyLoadManyPath(String lazyLoadManyPath); - - /** - * Convert any many joins fetch joins to query joins. - */ - public void convertManyFetchJoinsToQueryJoins(boolean allowOne, int queryBatch); - - /** - * Return the TransactionContext. - *

- * If no TransactionContext is present on the query then the - * TransactionContext from the Transaction is used (transaction scoped - * persistence context). - *

- */ - public PersistenceContext getPersistenceContext(); - - /** - * Set an explicit TransactionContext (typically for a refresh query). - *

- * If no TransactionContext is present on the query then the - * TransactionContext from the Transaction is used (transaction scoped - * persistence context). - *

- */ - public void setPersistenceContext(PersistenceContext transactionContext); - - /** - * Return true if the query detail has neither select or joins specified. - */ - public boolean isDetailEmpty(); - - /** - * Return explicit autoFetch setting or null. If null then not explicitly - * set so we use the default behaviour. - */ - public Boolean isAutofetch(); - - /** - * Set to true if you want to capture executed secondary queries. - */ - public void setLogSecondaryQuery(boolean logSecondaryQuery); - - /** - * Return true if executed secondary queries should be captured. - */ - public boolean isLogSecondaryQuery(); - - /** - * Return the list of secondary queries that were executed. - */ - public List> getLoggedSecondaryQueries(); - - /** - * Log an executed secondary query. - */ - public void logSecondaryQuery(SpiQuery query); - - /** - * If return null then no autoFetch profiling for this query. If a - * AutoFetchManager is returned this implies that profiling is turned on for - * this query (and all the objects this query creates). - */ - public AutoFetchManager getAutoFetchManager(); - - /** - * This has the effect of turning on autoFetch profiling for this query. - */ - public void setAutoFetchManager(AutoFetchManager manager); - - /** - * Return the origin point for the query. - *

- * This MUST be call prior to a query being changed via tuning. This is - * because the queryPlanHash is used to identify the query point. - *

- */ - public ObjectGraphNode setOrigin(CallStack callStack); - - /** - * Set the profile point of the bean or collection that is lazy loading. - *

- * This enables use to hook this back to the original 'root' query by the - * queryPlanHash and stackPoint. - *

- */ - public void setParentNode(ObjectGraphNode node); - - /** - * Set the property that invoked the lazy load and MUST be included in the - * lazy loading query. - */ - public void setLazyLoadProperty(String lazyLoadProperty); - - /** - * Return the property that invoked lazy load. - */ - public String getLazyLoadProperty(); - - /** - * Return the lazy load path. - */ - public String getLazyLoadManyPath(); - - /** - * Used to hook back a lazy loading query to the original query (query - * point). - *

- * This will return null or an "original" query. - *

- */ - public ObjectGraphNode getParentNode(); - - /** - * Return false when this is a lazy load or refresh query for a bean. - *

- * We just take/copy the data from those beans and don't collect autoFetch - * usage profiling on those lazy load or refresh beans. - *

- */ - public boolean isUsageProfiling(); - - /** - * Set to false if this query should not be included in the autoFetch usage - * profiling information. - */ - public void setUsageProfiling(boolean usageProfiling); - - /** - * Return the query name. - */ - public String getName(); - - /** - * Calculate a hash used by AutoFetch to identify when a query has changed - * (and hence potentially needs a new tuned query plan to be developed). - *

- * Excludes bind values and occurs prior to AutoFetch potentially - * tuning/modifying the query. - *

- */ - public HashQueryPlan queryAutofetchHash(HashQueryPlanBuilder builder); - - /** - * Identifies queries that are the same bar the bind variables. - *

- * This is used AFTER AutoFetch has potentially tuned the query. This is - * used to identify and reused query plans (the final SQL string and - * associated SqlTree object). - *

- *

- * Excludes the actual bind values (as they don't effect the query plan). - *

- */ - public HashQueryPlan queryPlanHash(BeanQueryRequest request); - - /** - * Calculate a hash based on the bind values used in the query. - *

- * Combined with queryPlanHash() to return getQueryHash (a unique hash for a - * query). - *

- */ - public int queryBindHash(); - - /** - * Identifies queries that are exactly the same including bind variables. - */ - public HashQuery queryHash(); - - /** - * Return true if this is a query based on a SqlSelect rather than - * generated. - */ - public boolean isSqlSelect(); - - /** - * Return true if this is a RawSql query. - */ - public boolean isRawSql(); - - /** - * Return the Order By clause or null if there is none defined. - */ - public OrderBy getOrderBy(); - - /** - * Return additional where clause. This should be added to any where clause - * that was part of the original query. - */ - public String getAdditionalWhere(); - - /** - * Can return null if no expressions where added to the where clause. - */ - public SpiExpressionList getWhereExpressions(); - - /** - * Can return null if no expressions where added to the having clause. - */ - public SpiExpressionList getHavingExpressions(); - - /** - * Return additional having clause. Where raw String expressions are added - * to having clause rather than Expression objects. - */ - public String getAdditionalHaving(); - - /** - * Returns true if either firstRow or maxRows has been set. - */ - public boolean hasMaxRowsOrFirstRow(); - - /** - * Return true if this query should use/check the bean cache. - */ - public Boolean isUseBeanCache(); - - /** - * Return true if this query should use/check the query cache. - */ - public boolean isUseQueryCache(); - - /** - * Return true if the beans from this query should be loaded into the bean - * cache. - */ - public boolean isLoadBeanCache(); - - /** - * Return true if the beans returned by this query should be read only. - */ - public Boolean isReadOnly(); - - /** - * Adds this bean to the persistence context prior to executing the query. - */ - public void contextAdd(EntityBean bean); - - /** - * Return the type of beans queries. - */ - public Class getBeanType(); - - /** - * Return the query timeout. - */ - public int getTimeout(); - - /** - * Return the objects that should be added to the persistence context prior - * to executing the query. - */ - public ArrayList getContextAdditions(); - - /** - * Return the bind parameters. - */ - public BindParams getBindParams(); - - /** - * Get the orm query as a String. Only available if the query was built from - * a string. - */ - public String getQuery(); - - /** - * Replace the query detail. This is used by the autoFetch feature to as a - * fast way to set the query properties and joins. - *

- * Note care must be taken to keep the where, orderBy, firstRows and maxRows - * held in the detail attributes. - *

- */ - public void setDetail(OrmQueryDetail detail); - - /** - * Autofetch tune the detail specifying properties to select on already defined joins - * and adding extra joins where they are missing. - */ - public boolean tuneFetchProperties(OrmQueryDetail detail); - - /** - * Set to true if this query has been tuned by autoFetch. - */ - public void setAutoFetchTuned(boolean autoFetchTuned); - - /** - * Return the query detail. - */ - public OrmQueryDetail getDetail(); - - public TableJoin getIncludeTableJoin(); - - public void setIncludeTableJoin(TableJoin includeTableJoin); - - /** - * Return the property used to specify keys for a map. - */ - public String getMapKey(); - - /** - * Return the maximum number of rows to return in the query. - */ - public int getMaxRows(); - - /** - * Return the index of the first row to return in the query. - */ - public int getFirstRow(); - - /** - * Internally set by Ebean when this query must use the DISTINCT keyword. - *

- * This does not exclude/remove the use of the id property. - */ - public Query setSqlDistinct(boolean sqlDistinct); - - /** - * Return true if this query has been specified by a user or internally by Ebean to use DISTINCT. - */ - public boolean isDistinctQuery(); - - /** - * Return true if this query has been specified by a user to use DISTINCT. - */ - public boolean isDistinct(); - - /** - * Set default select clauses where none have been explicitly defined. - */ - public void setDefaultSelectClause(); - - /** - * Return the where clause from a parsed string query. - */ - public String getRawWhereClause(); - - /** - * Return the Id value. - */ - public Object getId(); - - /** - * Set the generated sql for debug purposes. - * - * @param generatedSql - */ - public void setGeneratedSql(String generatedSql); - - /** - * Return the hint for Statement.setFetchSize(). - */ - public int getBufferFetchSizeHint(); - - /** - * Return true if this is a query executing in the background. - */ - public boolean isFutureFetch(); - - /** - * Set to true to indicate the query is executing in a background thread - * asynchronously. - */ - public void setFutureFetch(boolean futureFetch); - - /** - * Set the underlying cancelable query (with the PreparedStatement). - */ - public void setCancelableQuery(CancelableQuery cancelableQuery); - - /** - * Return true if this query has been cancelled. - */ - public boolean isCancelled(); - - /** - * Return root table alias set by {@link #alias(String)} command. - */ - public String getAlias(); -} +package com.avaje.ebeaninternal.api; + +import java.util.ArrayList; +import java.util.List; + +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.OrderBy; +import com.avaje.ebean.PersistenceContextScope; +import com.avaje.ebean.Query; +import com.avaje.ebean.bean.BeanCollectionTouched; +import com.avaje.ebean.bean.CallStack; +import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebean.bean.ObjectGraphNode; +import com.avaje.ebean.bean.PersistenceContext; +import com.avaje.ebean.event.BeanQueryRequest; +import com.avaje.ebeaninternal.server.autofetch.AutoFetchManager; +import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; +import com.avaje.ebeaninternal.server.deploy.TableJoin; +import com.avaje.ebeaninternal.server.query.CancelableQuery; +import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; +import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail; +import com.avaje.ebeaninternal.server.querydefn.OrmQueryProperties; + +/** + * Object Relational query - Internal extension to Query object. + */ +public interface SpiQuery extends Query { + + public enum Mode { + NORMAL(false), LAZYLOAD_MANY(false), LAZYLOAD_BEAN(true), REFRESH_BEAN(true); + Mode(boolean loadContextBean) { + this.loadContextBean = loadContextBean; + } + + private final boolean loadContextBean; + + public boolean isLoadContextBean() { + return loadContextBean; + } + } + + /** + * The type of query result. + */ + public enum Type { + + /** + * Find by Id or unique returning a single bean. + */ + BEAN, + + /** + * Find returning a List. + */ + LIST, + + /** + * Find returning a Set. + */ + SET, + + /** + * Find returning a Map. + */ + MAP, + + /** + * Find the Id's. + */ + ID_LIST, + + /** + * Find rowCount. + */ + ROWCOUNT, + + /** + * A subquery used as part of a where clause. + */ + SUBQUERY + } + + /** + * Return the PersistenceContextScope that this query should use. + *

+ * This can be null and in that case use the default scope. + *

+ */ + public PersistenceContextScope getPersistenceContextScope(); + + /** + * Return the default lazy load batch size. + */ + public int getLazyLoadBatchSize(); + + /** + * Return true if select all properties was used to ensure the property + * invoking a lazy load was included in the query. + */ + public boolean selectAllForLazyLoadProperty(); + + /** + * Set the query mode. + */ + public void setMode(Mode m); + + /** + * Return the query mode. + */ + public Mode getMode(); + + /** + * Return a listener that wants to be notified when the bean collection is + * first used. + */ + public BeanCollectionTouched getBeanCollectionTouched(); + + /** + * Set a listener to be notified when the bean collection has been touched + * (when the list/set/map is first used). + */ + public void setBeanCollectionTouched(BeanCollectionTouched notify); + + /** + * Set the list of Id's that is being populated. + *

+ * This is a mutating list of id's and we are setting this so that other + * threads have access to the id's before the id query has finished. + *

+ */ + public void setIdList(List ids); + + /** + * Return the list of Id's that is currently being fetched by a background + * thread. + */ + public List getIdList(); + + /** + * Return a copy of the query. + */ + public SpiQuery copy(); + + /** + * Return the type of query (List, Set, Map, Bean, rowCount etc). + */ + public Type getType(); + + /** + * Set the query type (List, Set etc). + */ + public void setType(Type type); + + /** + * Return a more detailed description of the lazy or query load. + */ + public String getLoadDescription(); + + /** + * Return the load mode (+lazy or +query). + */ + public String getLoadMode(); + + /** + * This becomes a lazy loading query for a many relationship. + */ + public void setLazyLoadForParents(List parentIds, BeanPropertyAssocMany many); + + /** + * Return the lazy loading 'many' property. + */ + public BeanPropertyAssocMany getLazyLoadForParentsProperty(); + + /** + * Return the list of parent Id's for lazy loading. + */ + public List getLazyLoadForParentIds(); + + /** + * Set the load mode (+lazy or +query) and the load description. + */ + public void setLoadDescription(String loadMode, String loadDescription); + + /** + * Set the BeanDescriptor for the root type of this query. + */ + public void setBeanDescriptor(BeanDescriptor desc); + + /** + * Initialise/determine the joins required to support 'many' where clause predicates. + */ + public boolean initManyWhereJoins(); + + /** + * Return the joins required to support predicates on the many properties. + */ + public ManyWhereJoins getManyWhereJoins(); + + /** + * Convert this natural key query into a find by id query. + */ + public void convertWhereNaturalKeyToId(Object idValue); + + /** + * Return a Natural Key bind parameter if supported by this query. + */ + public NaturalKeyBindParam getNaturalKeyBindParam(); + + /** + * Set the query to select the id property only. + */ + public void setSelectId(); + + /** + * Set a filter to a join path. + */ + public void setFilterMany(String prop, ExpressionList filterMany); + + /** + * Remove the query joins from query detail. + *

+ * These are registered with the Load Context. + *

+ */ + public List removeQueryJoins(); + + /** + * Remove the lazy joins from query detail. + *

+ * These are registered with the Load Context. + *

+ */ + public List removeLazyJoins(); + + /** + * Set the path of the many when +query/+lazy loading query is executed. + */ + public void setLazyLoadManyPath(String lazyLoadManyPath); + + /** + * Convert any many joins fetch joins to query joins. + */ + public void convertManyFetchJoinsToQueryJoins(boolean allowOne, int queryBatch); + + /** + * Return the TransactionContext. + *

+ * If no TransactionContext is present on the query then the + * TransactionContext from the Transaction is used (transaction scoped + * persistence context). + *

+ */ + public PersistenceContext getPersistenceContext(); + + /** + * Set an explicit TransactionContext (typically for a refresh query). + *

+ * If no TransactionContext is present on the query then the + * TransactionContext from the Transaction is used (transaction scoped + * persistence context). + *

+ */ + public void setPersistenceContext(PersistenceContext transactionContext); + + /** + * Return true if the query detail has neither select or joins specified. + */ + public boolean isDetailEmpty(); + + /** + * Return explicit autoFetch setting or null. If null then not explicitly + * set so we use the default behaviour. + */ + public Boolean isAutofetch(); + + /** + * Set to true if you want to capture executed secondary queries. + */ + public void setLogSecondaryQuery(boolean logSecondaryQuery); + + /** + * Return true if executed secondary queries should be captured. + */ + public boolean isLogSecondaryQuery(); + + /** + * Return the list of secondary queries that were executed. + */ + public List> getLoggedSecondaryQueries(); + + /** + * Log an executed secondary query. + */ + public void logSecondaryQuery(SpiQuery query); + + /** + * If return null then no autoFetch profiling for this query. If a + * AutoFetchManager is returned this implies that profiling is turned on for + * this query (and all the objects this query creates). + */ + public AutoFetchManager getAutoFetchManager(); + + /** + * This has the effect of turning on autoFetch profiling for this query. + */ + public void setAutoFetchManager(AutoFetchManager manager); + + /** + * Return the origin point for the query. + *

+ * This MUST be call prior to a query being changed via tuning. This is + * because the queryPlanHash is used to identify the query point. + *

+ */ + public ObjectGraphNode setOrigin(CallStack callStack); + + /** + * Set the profile point of the bean or collection that is lazy loading. + *

+ * This enables use to hook this back to the original 'root' query by the + * queryPlanHash and stackPoint. + *

+ */ + public void setParentNode(ObjectGraphNode node); + + /** + * Set the property that invoked the lazy load and MUST be included in the + * lazy loading query. + */ + public void setLazyLoadProperty(String lazyLoadProperty); + + /** + * Return the property that invoked lazy load. + */ + public String getLazyLoadProperty(); + + /** + * Return the lazy load path. + */ + public String getLazyLoadManyPath(); + + /** + * Used to hook back a lazy loading query to the original query (query + * point). + *

+ * This will return null or an "original" query. + *

+ */ + public ObjectGraphNode getParentNode(); + + /** + * Return false when this is a lazy load or refresh query for a bean. + *

+ * We just take/copy the data from those beans and don't collect autoFetch + * usage profiling on those lazy load or refresh beans. + *

+ */ + public boolean isUsageProfiling(); + + /** + * Set to false if this query should not be included in the autoFetch usage + * profiling information. + */ + public void setUsageProfiling(boolean usageProfiling); + + /** + * Return the query name. + */ + public String getName(); + + /** + * Calculate a hash used by AutoFetch to identify when a query has changed + * (and hence potentially needs a new tuned query plan to be developed). + *

+ * Excludes bind values and occurs prior to AutoFetch potentially + * tuning/modifying the query. + *

+ */ + public HashQueryPlan queryAutofetchHash(HashQueryPlanBuilder builder); + + /** + * Identifies queries that are the same bar the bind variables. + *

+ * This is used AFTER AutoFetch has potentially tuned the query. This is + * used to identify and reused query plans (the final SQL string and + * associated SqlTree object). + *

+ *

+ * Excludes the actual bind values (as they don't effect the query plan). + *

+ */ + public HashQueryPlan queryPlanHash(BeanQueryRequest request); + + /** + * Calculate a hash based on the bind values used in the query. + *

+ * Combined with queryPlanHash() to return getQueryHash (a unique hash for a + * query). + *

+ */ + public int queryBindHash(); + + /** + * Identifies queries that are exactly the same including bind variables. + */ + public HashQuery queryHash(); + + /** + * Return true if this is a query based on a SqlSelect rather than + * generated. + */ + public boolean isSqlSelect(); + + /** + * Return true if this is a RawSql query. + */ + public boolean isRawSql(); + + /** + * Return the Order By clause or null if there is none defined. + */ + public OrderBy getOrderBy(); + + /** + * Return additional where clause. This should be added to any where clause + * that was part of the original query. + */ + public String getAdditionalWhere(); + + /** + * Can return null if no expressions where added to the where clause. + */ + public SpiExpressionList getWhereExpressions(); + + /** + * Can return null if no expressions where added to the having clause. + */ + public SpiExpressionList getHavingExpressions(); + + /** + * Return additional having clause. Where raw String expressions are added + * to having clause rather than Expression objects. + */ + public String getAdditionalHaving(); + + /** + * Returns true if either firstRow or maxRows has been set. + */ + public boolean hasMaxRowsOrFirstRow(); + + /** + * Return true if this query should use/check the bean cache. + */ + public Boolean isUseBeanCache(); + + /** + * Return true if this query should use/check the query cache. + */ + public boolean isUseQueryCache(); + + /** + * Return true if the beans from this query should be loaded into the bean + * cache. + */ + public boolean isLoadBeanCache(); + + /** + * Return true if the beans returned by this query should be read only. + */ + public Boolean isReadOnly(); + + /** + * Adds this bean to the persistence context prior to executing the query. + */ + public void contextAdd(EntityBean bean); + + /** + * Return the type of beans queries. + */ + public Class getBeanType(); + + /** + * Return the query timeout. + */ + public int getTimeout(); + + /** + * Return the objects that should be added to the persistence context prior + * to executing the query. + */ + public ArrayList getContextAdditions(); + + /** + * Return the bind parameters. + */ + public BindParams getBindParams(); + + /** + * Get the orm query as a String. Only available if the query was built from + * a string. + */ + public String getQuery(); + + /** + * Replace the query detail. This is used by the autoFetch feature to as a + * fast way to set the query properties and joins. + *

+ * Note care must be taken to keep the where, orderBy, firstRows and maxRows + * held in the detail attributes. + *

+ */ + public void setDetail(OrmQueryDetail detail); + + /** + * Autofetch tune the detail specifying properties to select on already defined joins + * and adding extra joins where they are missing. + */ + public boolean tuneFetchProperties(OrmQueryDetail detail); + + /** + * Set to true if this query has been tuned by autoFetch. + */ + public void setAutoFetchTuned(boolean autoFetchTuned); + + /** + * Return the query detail. + */ + public OrmQueryDetail getDetail(); + + public TableJoin getIncludeTableJoin(); + + public void setIncludeTableJoin(TableJoin includeTableJoin); + + /** + * Return the property used to specify keys for a map. + */ + public String getMapKey(); + + /** + * Return the maximum number of rows to return in the query. + */ + public int getMaxRows(); + + /** + * Return the index of the first row to return in the query. + */ + public int getFirstRow(); + + /** + * Internally set by Ebean when this query must use the DISTINCT keyword. + *

+ * This does not exclude/remove the use of the id property. + */ + public Query setSqlDistinct(boolean sqlDistinct); + + /** + * Return true if this query has been specified by a user or internally by Ebean to use DISTINCT. + */ + public boolean isDistinctQuery(); + + /** + * Return true if this query has been specified by a user to use DISTINCT. + */ + public boolean isDistinct(); + + /** + * Set default select clauses where none have been explicitly defined. + */ + public void setDefaultSelectClause(); + + /** + * Return the where clause from a parsed string query. + */ + public String getRawWhereClause(); + + /** + * Return the Id value. + */ + public Object getId(); + + /** + * Set the generated sql for debug purposes. + * + * @param generatedSql + */ + public void setGeneratedSql(String generatedSql); + + /** + * Return the hint for Statement.setFetchSize(). + */ + public int getBufferFetchSizeHint(); + + /** + * Return true if this is a query executing in the background. + */ + public boolean isFutureFetch(); + + /** + * Set to true to indicate the query is executing in a background thread + * asynchronously. + */ + public void setFutureFetch(boolean futureFetch); + + /** + * Set the underlying cancelable query (with the PreparedStatement). + */ + public void setCancelableQuery(CancelableQuery cancelableQuery); + + /** + * Return true if this query has been cancelled. + */ + public boolean isCancelled(); + + /** + * Return root table alias set by {@link #alias(String)} command. + */ + public String getAlias(); +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java index b53accde0..8b095b70a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java @@ -1,231 +1,231 @@ -package com.avaje.ebeaninternal.api; - -import java.sql.Connection; -import java.util.List; - -import com.avaje.ebean.Transaction; -import com.avaje.ebean.bean.PersistenceContext; -import com.avaje.ebeaninternal.server.core.PersistRequest; -import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.persist.BatchControl; - -/** - * Extends Transaction with additional API required on server. - *

- * Provides support for batching and TransactionContext. - *

- */ -public interface SpiTransaction extends Transaction { - - /** - * End the transaction when had query only use. - */ - public void endQueryOnly(); - - /** - * Return the string prefix with the transactin id and label used in logging. - */ - public String getLogPrefix(); - - /** - * Return true if generated SQL and Bind values should be logged to the - * transaction log. - */ - public boolean isLogSql(); - - /** - * Return true if summary level events should be logged to the transaction - * log. - */ - public boolean isLogSummary(); - - /** - * Log a message to the SQL logger. - */ - public void logSql(String msg); - - /** - * Log a message to the SUMMARY logger. - */ - public void logSummary(String msg); - - /** - * Register a "Derived Relationship" (that requires an additional update). - */ - public void registerDerivedRelationship(DerivedRelationshipData assocBean); - - /** - * Return the list of "Derived Relationships" that must be maintained after - * insert. - */ - public List getDerivedRelationship(Object bean); - - /** - * Add a deleting bean to the registered list. - *

- * This is to handle bi-directional relationships where both sides Cascade. - *

- */ - public void registerDeleteBean(Integer hash); - - /** - * Unregister the hash of the bean. - */ - public void unregisterDeleteBean(Integer hash); - - /** - * Return true if this is a bean that has already been saved/deleted. - */ - public boolean isRegisteredDeleteBean(Integer hash); - - /** - * Unregister the persisted bean. - */ - public void unregisterBean(Object bean); - - /** - * Return true if this is a bean that has already been persisted in the - * current recursive save request. The goal is to stop recursively saving - * the bean when cascade persist is on both sides of a relationship). - *

- * This will register the bean if it is not already. - *

- */ - public boolean isRegisteredBean(Object bean); - - /** - * Returns a String used to identify the transaction. This id is used for - * Transaction logging. - */ - public String getId(); - - /** - * Return the batchSize specifically set for this transaction or 0. - *

- * Returning 0 implies to use the system wide default batch size. - *

- */ - public int getBatchSize(); - - /** - * Modify and return the current 'depth' of the transaction. - *

- * As we cascade save or delete we traverse the object graph tree. Going up - * to Assoc Ones the depth decreases and going down to Assoc Manys the depth - * increases. - *

- *

- * The depth is used for ordering batching statements. The lowest depth get - * executed first during save. - *

- */ - public int depth(int diff); - - /** - * Return the current depth. - */ - public int depth(); - - /** - * Return true if this transaction was created explicitly via - * Ebean.beginTransaction(). - */ - public boolean isExplicit(); - - /** - * Get the object that holds the event details. - *

- * This information is used maintain the table state, cache and text - * indexes. On commit the Table modifications this generates is broadcast - * around the cluster (if you have a cluster). - *

- */ - public TransactionEvent getEvent(); - - /** - * Whether persistCascade is on for save and delete. - */ - public boolean isPersistCascade(); - - /** - * Return true if this request should be batched. Conversely returns false - * if this request should be executed immediately. - */ - public boolean isBatchThisRequest(PersistRequest.Type type); - - /** - * Return the queue used to batch up persist requests. - */ - public BatchControl getBatchControl(); - - /** - * Set the queue used to batch up persist requests. There should only be one - * PersistQueue set per transaction. - */ - public void setBatchControl(BatchControl control); - - /** - * Return the persistence context associated with this transaction. - *

- * You may wish to hold onto this and set it against another transaction - * later. This is along the lines of 'extended persistence context' - * behaviour. - *

- */ - public PersistenceContext getPersistenceContext(); - - /** - * Set the persistence context to this transaction. - *

- * This could be considered similar to 'EJB3 Extended Persistence Context'. - * In that you can get the PersistenceContext from a transaction, hold onto - * it, and then set it back later to a second transaction. In general there - * is one PersistenceContext per Transaction. The getPersistenceContext() - * and setPersistenceContext() enable a developer to reuse a single - * PersistenceContext with multiple transactions. - *

- */ - public void setPersistenceContext(PersistenceContext context); - - /** - * Return the underlying Connection for internal use. - *

- * If the connection is made public from Transaction and the user code calls - * that method we can no longer trust the query only status of a - * Transaction. - *

- */ - public Connection getInternalConnection(); - - /** - * Return true if the manyToMany intersection should be persisted for this particular relationship direction. - */ - public boolean isSaveAssocManyIntersection(String intersectionTable, String beanName); - - /** - * Return true if batch mode got escalated for this request (and associated cascades). - */ - public boolean checkBatchEscalationOnCascade(PersistRequestBean request); - - /** - * If batch mode was turned on for the request then flush the batch. - */ - public void flushBatchOnCascade(); - - /** - * Mark the transaction explicitly as not being query only. - */ - public void markNotQueryOnly(); - - /** - * Potentially escalate batch mode on saving or deleting a collection. - */ - public void checkBatchEscalationOnCollection(); - - /** - * Flush batch if we escalated batch mode on saving or deleting a collection. - */ - public void flushBatchOnCollection(); - - -} +package com.avaje.ebeaninternal.api; + +import java.sql.Connection; +import java.util.List; + +import com.avaje.ebean.Transaction; +import com.avaje.ebean.bean.PersistenceContext; +import com.avaje.ebeaninternal.server.core.PersistRequest; +import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import com.avaje.ebeaninternal.server.persist.BatchControl; + +/** + * Extends Transaction with additional API required on server. + *

+ * Provides support for batching and TransactionContext. + *

+ */ +public interface SpiTransaction extends Transaction { + + /** + * End the transaction when had query only use. + */ + public void endQueryOnly(); + + /** + * Return the string prefix with the transactin id and label used in logging. + */ + public String getLogPrefix(); + + /** + * Return true if generated SQL and Bind values should be logged to the + * transaction log. + */ + public boolean isLogSql(); + + /** + * Return true if summary level events should be logged to the transaction + * log. + */ + public boolean isLogSummary(); + + /** + * Log a message to the SQL logger. + */ + public void logSql(String msg); + + /** + * Log a message to the SUMMARY logger. + */ + public void logSummary(String msg); + + /** + * Register a "Derived Relationship" (that requires an additional update). + */ + public void registerDerivedRelationship(DerivedRelationshipData assocBean); + + /** + * Return the list of "Derived Relationships" that must be maintained after + * insert. + */ + public List getDerivedRelationship(Object bean); + + /** + * Add a deleting bean to the registered list. + *

+ * This is to handle bi-directional relationships where both sides Cascade. + *

+ */ + public void registerDeleteBean(Integer hash); + + /** + * Unregister the hash of the bean. + */ + public void unregisterDeleteBean(Integer hash); + + /** + * Return true if this is a bean that has already been saved/deleted. + */ + public boolean isRegisteredDeleteBean(Integer hash); + + /** + * Unregister the persisted bean. + */ + public void unregisterBean(Object bean); + + /** + * Return true if this is a bean that has already been persisted in the + * current recursive save request. The goal is to stop recursively saving + * the bean when cascade persist is on both sides of a relationship). + *

+ * This will register the bean if it is not already. + *

+ */ + public boolean isRegisteredBean(Object bean); + + /** + * Returns a String used to identify the transaction. This id is used for + * Transaction logging. + */ + public String getId(); + + /** + * Return the batchSize specifically set for this transaction or 0. + *

+ * Returning 0 implies to use the system wide default batch size. + *

+ */ + public int getBatchSize(); + + /** + * Modify and return the current 'depth' of the transaction. + *

+ * As we cascade save or delete we traverse the object graph tree. Going up + * to Assoc Ones the depth decreases and going down to Assoc Manys the depth + * increases. + *

+ *

+ * The depth is used for ordering batching statements. The lowest depth get + * executed first during save. + *

+ */ + public int depth(int diff); + + /** + * Return the current depth. + */ + public int depth(); + + /** + * Return true if this transaction was created explicitly via + * Ebean.beginTransaction(). + */ + public boolean isExplicit(); + + /** + * Get the object that holds the event details. + *

+ * This information is used maintain the table state, cache and text + * indexes. On commit the Table modifications this generates is broadcast + * around the cluster (if you have a cluster). + *

+ */ + public TransactionEvent getEvent(); + + /** + * Whether persistCascade is on for save and delete. + */ + public boolean isPersistCascade(); + + /** + * Return true if this request should be batched. Conversely returns false + * if this request should be executed immediately. + */ + public boolean isBatchThisRequest(PersistRequest.Type type); + + /** + * Return the queue used to batch up persist requests. + */ + public BatchControl getBatchControl(); + + /** + * Set the queue used to batch up persist requests. There should only be one + * PersistQueue set per transaction. + */ + public void setBatchControl(BatchControl control); + + /** + * Return the persistence context associated with this transaction. + *

+ * You may wish to hold onto this and set it against another transaction + * later. This is along the lines of 'extended persistence context' + * behaviour. + *

+ */ + public PersistenceContext getPersistenceContext(); + + /** + * Set the persistence context to this transaction. + *

+ * This could be considered similar to 'EJB3 Extended Persistence Context'. + * In that you can get the PersistenceContext from a transaction, hold onto + * it, and then set it back later to a second transaction. In general there + * is one PersistenceContext per Transaction. The getPersistenceContext() + * and setPersistenceContext() enable a developer to reuse a single + * PersistenceContext with multiple transactions. + *

+ */ + public void setPersistenceContext(PersistenceContext context); + + /** + * Return the underlying Connection for internal use. + *

+ * If the connection is made public from Transaction and the user code calls + * that method we can no longer trust the query only status of a + * Transaction. + *

+ */ + public Connection getInternalConnection(); + + /** + * Return true if the manyToMany intersection should be persisted for this particular relationship direction. + */ + public boolean isSaveAssocManyIntersection(String intersectionTable, String beanName); + + /** + * Return true if batch mode got escalated for this request (and associated cascades). + */ + public boolean checkBatchEscalationOnCascade(PersistRequestBean request); + + /** + * If batch mode was turned on for the request then flush the batch. + */ + public void flushBatchOnCascade(); + + /** + * Mark the transaction explicitly as not being query only. + */ + public void markNotQueryOnly(); + + /** + * Potentially escalate batch mode on saving or deleting a collection. + */ + public void checkBatchEscalationOnCollection(); + + /** + * Flush batch if we escalated batch mode on saving or deleting a collection. + */ + public void flushBatchOnCollection(); + + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java index 9ac23a9af..f89b87f3b 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java @@ -1,75 +1,75 @@ -package com.avaje.ebeaninternal.api; - -import java.sql.SQLException; - -import com.avaje.ebean.annotation.ConcurrencyMode; -import com.avaje.ebean.bean.EntityBean; -import com.avaje.ebeaninternal.server.persist.dml.DmlHandler; -import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; - -/** - * A plan for executing bean updates for a given set of changed properties. - *

- * This is a cachable plan with the purpose of being being able to skip some - * phases of the update bean processing. - *

- *

- * The plans are cached by the BeanDescriptors. - * - * - * @author rbygrave - */ -public interface SpiUpdatePlan { - - /** - * Return true if the set clause has no columns. - *

- * Can occur when the only columns updated have a updatable=false in their - * deployment. - *

- */ - public boolean isEmptySetClause(); - - /** - * Bind given the request and bean. The bean could be the oldValues bean - * when binding a update or delete where clause with ALL concurrency mode. - */ - public void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - - /** - * Return the time this plan was created. - */ - public long getTimeCreated(); - - /** - * Return the time this plan was last used. - */ - public Long getTimeLastUsed(); - - /** - * Return the hash key for this plan. - */ - public Integer getKey(); - - /** - * Return the concurrency mode for this plan. - */ - public ConcurrencyMode getMode(); - - /** - * Return the update SQL statement. - */ - public String getSql(); - - /** - * Return the set of bindable update properties. - */ - public Bindable getSet(); - -// /** -// * Return the properties that where changed and should be included in the -// * update statement. -// */ -// public Set getProperties(); - +package com.avaje.ebeaninternal.api; + +import java.sql.SQLException; + +import com.avaje.ebean.annotation.ConcurrencyMode; +import com.avaje.ebean.bean.EntityBean; +import com.avaje.ebeaninternal.server.persist.dml.DmlHandler; +import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; + +/** + * A plan for executing bean updates for a given set of changed properties. + *

+ * This is a cachable plan with the purpose of being being able to skip some + * phases of the update bean processing. + *

+ *

+ * The plans are cached by the BeanDescriptors. + * + * + * @author rbygrave + */ +public interface SpiUpdatePlan { + + /** + * Return true if the set clause has no columns. + *

+ * Can occur when the only columns updated have a updatable=false in their + * deployment. + *

+ */ + public boolean isEmptySetClause(); + + /** + * Bind given the request and bean. The bean could be the oldValues bean + * when binding a update or delete where clause with ALL concurrency mode. + */ + public void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; + + /** + * Return the time this plan was created. + */ + public long getTimeCreated(); + + /** + * Return the time this plan was last used. + */ + public Long getTimeLastUsed(); + + /** + * Return the hash key for this plan. + */ + public Integer getKey(); + + /** + * Return the concurrency mode for this plan. + */ + public ConcurrencyMode getMode(); + + /** + * Return the update SQL statement. + */ + public String getSql(); + + /** + * Return the set of bindable update properties. + */ + public Bindable getSet(); + +// /** +// * Return the properties that where changed and should be included in the +// * update statement. +// */ +// public Set getProperties(); + } \ No newline at end of file diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java index 4945590d9..03dd91889 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java @@ -1,123 +1,123 @@ -package com.avaje.ebeaninternal.api; - -import com.avaje.ebeaninternal.server.core.PersistRequestBean; -import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; -import com.avaje.ebeaninternal.server.transaction.DeleteByIdMap; - -import java.io.Serializable; -import java.util.List; - -/** - * Holds information for a transaction. There is one TransactionEvent instance - * per Transaction instance. - *

- * When the associated Transaction commits or rollback this information is sent - * to the TransactionEventManager. - *

- */ -public class TransactionEvent implements Serializable { - - private static final long serialVersionUID = 7230903304106097120L; - - /** - * Flag indicating this is a local transaction (not from another server in - * the cluster). - */ - private transient boolean local; - - private TransactionEventTable eventTables; - - private transient TransactionEventBeans eventBeans; - - private transient DeleteByIdMap deleteByIdMap; - - /** - * Create the TransactionEvent, one per Transaction. - */ - public TransactionEvent() { - this.local = true; - } - - public void addDeleteById(BeanDescriptor desc, Object id) { - if (deleteByIdMap == null) { - deleteByIdMap = new DeleteByIdMap(); - } - deleteByIdMap.add(desc, id); - } - - public void addDeleteByIdList(BeanDescriptor desc, List idList) { - if (deleteByIdMap == null) { - deleteByIdMap = new DeleteByIdMap(); - } - deleteByIdMap.addList(desc, idList); - } - - public DeleteByIdMap getDeleteByIdMap() { - return deleteByIdMap; - } - - /** - * Return true if this was a local transaction. Returns false if this - * transaction originated on another server in the cluster. - */ - public boolean isLocal() { - return local; - } - - /** - * For BeanListeners the requests they are interested in. - */ - public TransactionEventBeans getEventBeans() { - return eventBeans; - } - - public TransactionEventTable getEventTables() { - return eventTables; - } - - public void add(String tableName, boolean inserts, boolean updates, boolean deletes) { - if (eventTables == null) { - eventTables = new TransactionEventTable(); - } - eventTables.add(tableName, inserts, updates, deletes); - } - - public void add(TransactionEventTable table) { - if (eventTables == null) { - eventTables = new TransactionEventTable(); - } - eventTables.add(table); - } - - /** - * Add a inserted updated or deleted bean to the event. - */ - public void add(PersistRequestBean request) { - - if (request.isNotify()) { - // either a BeanListener or Cache is interested - if (eventBeans == null) { - eventBeans = new TransactionEventBeans(); - } - eventBeans.add(request); - } - } - - /** - * Notify the cache of bean changes. - *

- * This returns the TransactionEventTable so that if any - * general table changes can also be used to invalidate - * parts of the cache. - *

- */ - public void notifyCache() { - if (eventBeans != null) { - eventBeans.notifyCache(); - } - if (deleteByIdMap != null) { - deleteByIdMap.notifyCache(); - } - } - -} +package com.avaje.ebeaninternal.api; + +import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import com.avaje.ebeaninternal.server.transaction.DeleteByIdMap; + +import java.io.Serializable; +import java.util.List; + +/** + * Holds information for a transaction. There is one TransactionEvent instance + * per Transaction instance. + *

+ * When the associated Transaction commits or rollback this information is sent + * to the TransactionEventManager. + *

+ */ +public class TransactionEvent implements Serializable { + + private static final long serialVersionUID = 7230903304106097120L; + + /** + * Flag indicating this is a local transaction (not from another server in + * the cluster). + */ + private transient boolean local; + + private TransactionEventTable eventTables; + + private transient TransactionEventBeans eventBeans; + + private transient DeleteByIdMap deleteByIdMap; + + /** + * Create the TransactionEvent, one per Transaction. + */ + public TransactionEvent() { + this.local = true; + } + + public void addDeleteById(BeanDescriptor desc, Object id) { + if (deleteByIdMap == null) { + deleteByIdMap = new DeleteByIdMap(); + } + deleteByIdMap.add(desc, id); + } + + public void addDeleteByIdList(BeanDescriptor desc, List idList) { + if (deleteByIdMap == null) { + deleteByIdMap = new DeleteByIdMap(); + } + deleteByIdMap.addList(desc, idList); + } + + public DeleteByIdMap getDeleteByIdMap() { + return deleteByIdMap; + } + + /** + * Return true if this was a local transaction. Returns false if this + * transaction originated on another server in the cluster. + */ + public boolean isLocal() { + return local; + } + + /** + * For BeanListeners the requests they are interested in. + */ + public TransactionEventBeans getEventBeans() { + return eventBeans; + } + + public TransactionEventTable getEventTables() { + return eventTables; + } + + public void add(String tableName, boolean inserts, boolean updates, boolean deletes) { + if (eventTables == null) { + eventTables = new TransactionEventTable(); + } + eventTables.add(tableName, inserts, updates, deletes); + } + + public void add(TransactionEventTable table) { + if (eventTables == null) { + eventTables = new TransactionEventTable(); + } + eventTables.add(table); + } + + /** + * Add a inserted updated or deleted bean to the event. + */ + public void add(PersistRequestBean request) { + + if (request.isNotify()) { + // either a BeanListener or Cache is interested + if (eventBeans == null) { + eventBeans = new TransactionEventBeans(); + } + eventBeans.add(request); + } + } + + /** + * Notify the cache of bean changes. + *

+ * This returns the TransactionEventTable so that if any + * general table changes can also be used to invalidate + * parts of the cache. + *

+ */ + public void notifyCache() { + if (eventBeans != null) { + eventBeans.notifyCache(); + } + if (deleteByIdMap != null) { + deleteByIdMap.notifyCache(); + } + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 9eb427cc0..1e976c3a1 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -1,40 +1,40 @@ -package com.avaje.ebeaninternal.api; - -import java.util.ArrayList; -import java.util.List; - -import com.avaje.ebeaninternal.server.core.PersistRequestBean; - -/** - * Lists of inserted updated and deleted beans that have a BeanPersistListener. - *

- * These beans will be sent to the appropriate BeanListeners after a successful - * commit of the transaction. - *

- */ -public class TransactionEventBeans { - - ArrayList> requests = new ArrayList>(); - - /** - * Return the list of PersistRequests that BeanListeners are interested in. - */ - public List> getRequests() { - return requests; - } - - /** - * Add a bean for BeanListener notification. - */ - public void add(PersistRequestBean request) { - - requests.add(request); - } - - public void notifyCache() { - for (int i = 0; i < requests.size(); i++) { - requests.get(i).notifyCache(); - } - } - -} +package com.avaje.ebeaninternal.api; + +import java.util.ArrayList; +import java.util.List; + +import com.avaje.ebeaninternal.server.core.PersistRequestBean; + +/** + * Lists of inserted updated and deleted beans that have a BeanPersistListener. + *

+ * These beans will be sent to the appropriate BeanListeners after a successful + * commit of the transaction. + *

+ */ +public class TransactionEventBeans { + + ArrayList> requests = new ArrayList>(); + + /** + * Return the list of PersistRequests that BeanListeners are interested in. + */ + public List> getRequests() { + return requests; + } + + /** + * Add a bean for BeanListener notification. + */ + public void add(PersistRequestBean request) { + + requests.add(request); + } + + public void notifyCache() { + for (int i = 0; i < requests.size(); i++) { + requests.get(i).notifyCache(); + } + } + +} diff --git a/src/main/java/com/avaje/ebeaninternal/jdbc/ConnectionDelegator.java b/src/main/java/com/avaje/ebeaninternal/jdbc/ConnectionDelegator.java index b7deda951..382728c2a 100644 --- a/src/main/java/com/avaje/ebeaninternal/jdbc/ConnectionDelegator.java +++ b/src/main/java/com/avaje/ebeaninternal/jdbc/ConnectionDelegator.java @@ -1,254 +1,254 @@ -package com.avaje.ebeaninternal.jdbc; - -import java.sql.Array; -import java.sql.Blob; -import java.sql.CallableStatement; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Savepoint; -import java.sql.Statement; -import java.sql.Struct; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; - -public class ConnectionDelegator implements Connection { - - private final Connection delegate; - - public ConnectionDelegator(Connection delegate) { - this.delegate = delegate; - } - - @Override - public void setSchema(String schema) throws SQLException { - delegate.setSchema(schema); - } - - @Override - public String getSchema() throws SQLException { - return delegate.getSchema(); - } - - @Override - public void abort(Executor executor) throws SQLException { - delegate.abort(executor); - } - - @Override - public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { - delegate.setNetworkTimeout(executor, milliseconds); - } - - @Override - public int getNetworkTimeout() throws SQLException { - return delegate.getNetworkTimeout(); - } - - public Statement createStatement() throws SQLException { - return delegate.createStatement(); - } - - public PreparedStatement prepareStatement(String sql) throws SQLException { - return delegate.prepareStatement(sql); - } - - public CallableStatement prepareCall(String sql) throws SQLException { - return delegate.prepareCall(sql); - } - - public String nativeSQL(String sql) throws SQLException { - return delegate.nativeSQL(sql); - } - - public void setAutoCommit(boolean autoCommit) throws SQLException { - delegate.setAutoCommit(autoCommit); - } - - public boolean getAutoCommit() throws SQLException { - return delegate.getAutoCommit(); - } - - public void commit() throws SQLException { - delegate.commit(); - } - - public void rollback() throws SQLException { - delegate.rollback(); - } - - public void close() throws SQLException { - delegate.close(); - } - - public boolean isClosed() throws SQLException { - return delegate.isClosed(); - } - - public DatabaseMetaData getMetaData() throws SQLException { - return delegate.getMetaData(); - } - - public void setReadOnly(boolean readOnly) throws SQLException { - delegate.setReadOnly(readOnly); - } - - public boolean isReadOnly() throws SQLException { - return delegate.isReadOnly(); - } - - public void setCatalog(String catalog) throws SQLException { - delegate.setCatalog(catalog); - } - - public String getCatalog() throws SQLException { - return delegate.getCatalog(); - } - - public void setTransactionIsolation(int level) throws SQLException { - delegate.setTransactionIsolation(level); - } - - public int getTransactionIsolation() throws SQLException { - return delegate.getTransactionIsolation(); - } - - public SQLWarning getWarnings() throws SQLException { - return delegate.getWarnings(); - } - - public void clearWarnings() throws SQLException { - delegate.clearWarnings(); - } - - public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { - return delegate.createStatement(resultSetType, resultSetConcurrency); - } - - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency); - } - - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - return delegate.prepareCall(sql, resultSetType, resultSetConcurrency); - } - - public Map> getTypeMap() throws SQLException { - return delegate.getTypeMap(); - } - - public void setTypeMap(Map> map) throws SQLException { - delegate.setTypeMap(map); - } - - public void setHoldability(int holdability) throws SQLException { - delegate.setHoldability(holdability); - } - - public int getHoldability() throws SQLException { - return delegate.getHoldability(); - } - - public Savepoint setSavepoint() throws SQLException { - return delegate.setSavepoint(); - } - - public Savepoint setSavepoint(String name) throws SQLException { - return delegate.setSavepoint(name); - } - - public void rollback(Savepoint savepoint) throws SQLException { - delegate.rollback(savepoint); - } - - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - delegate.releaseSavepoint(savepoint); - } - - public Statement createStatement(int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); - } - - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - return delegate.prepareStatement(sql, autoGeneratedKeys); - } - - public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { - return delegate.prepareStatement(sql, columnIndexes); - } - - public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { - return delegate.prepareStatement(sql, columnNames); - } - - public Clob createClob() throws SQLException { - return delegate.createClob(); - } - - public Blob createBlob() throws SQLException { - return delegate.createBlob(); - } - - public NClob createNClob() throws SQLException { - return delegate.createNClob(); - } - - public SQLXML createSQLXML() throws SQLException { - return delegate.createSQLXML(); - } - - public boolean isValid(int timeout) throws SQLException { - return delegate.isValid(timeout); - } - - public void setClientInfo(String name, String value) throws SQLClientInfoException { - delegate.setClientInfo(name, value); - } - - public void setClientInfo(Properties properties) throws SQLClientInfoException { - delegate.setClientInfo(properties); - } - - public String getClientInfo(String name) throws SQLException { - return delegate.getClientInfo(name); - } - - public Properties getClientInfo() throws SQLException { - return delegate.getClientInfo(); - } - - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - return delegate.createArrayOf(typeName, elements); - } - - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - return delegate.createStruct(typeName, attributes); - } - - public T unwrap(Class iface) throws SQLException { - return delegate.unwrap(iface); - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return delegate.isWrapperFor(iface); - } -} +package com.avaje.ebeaninternal.jdbc; + +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.NClob; +import java.sql.PreparedStatement; +import java.sql.SQLClientInfoException; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Struct; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +public class ConnectionDelegator implements Connection { + + private final Connection delegate; + + public ConnectionDelegator(Connection delegate) { + this.delegate = delegate; + } + + @Override + public void setSchema(String schema) throws SQLException { + delegate.setSchema(schema); + } + + @Override + public String getSchema() throws SQLException { + return delegate.getSchema(); + } + + @Override + public void abort(Executor executor) throws SQLException { + delegate.abort(executor); + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + delegate.setNetworkTimeout(executor, milliseconds); + } + + @Override + public int getNetworkTimeout() throws SQLException { + return delegate.getNetworkTimeout(); + } + + public Statement createStatement() throws SQLException { + return delegate.createStatement(); + } + + public PreparedStatement prepareStatement(String sql) throws SQLException { + return delegate.prepareStatement(sql); + } + + public CallableStatement prepareCall(String sql) throws SQLException { + return delegate.prepareCall(sql); + } + + public String nativeSQL(String sql) throws SQLException { + return delegate.nativeSQL(sql); + } + + public void setAutoCommit(boolean autoCommit) throws SQLException { + delegate.setAutoCommit(autoCommit); + } + + public boolean getAutoCommit() throws SQLException { + return delegate.getAutoCommit(); + } + + public void commit() throws SQLException { + delegate.commit(); + } + + public void rollback() throws SQLException { + delegate.rollback(); + } + + public void close() throws SQLException { + delegate.close(); + } + + public boolean isClosed() throws SQLException { + return delegate.isClosed(); + } + + public DatabaseMetaData getMetaData() throws SQLException { + return delegate.getMetaData(); + } + + public void setReadOnly(boolean readOnly) throws SQLException { + delegate.setReadOnly(readOnly); + } + + public boolean isReadOnly() throws SQLException { + return delegate.isReadOnly(); + } + + public void setCatalog(String catalog) throws SQLException { + delegate.setCatalog(catalog); + } + + public String getCatalog() throws SQLException { + return delegate.getCatalog(); + } + + public void setTransactionIsolation(int level) throws SQLException { + delegate.setTransactionIsolation(level); + } + + public int getTransactionIsolation() throws SQLException { + return delegate.getTransactionIsolation(); + } + + public SQLWarning getWarnings() throws SQLException { + return delegate.getWarnings(); + } + + public void clearWarnings() throws SQLException { + delegate.clearWarnings(); + } + + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { + return delegate.createStatement(resultSetType, resultSetConcurrency); + } + + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency); + } + + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return delegate.prepareCall(sql, resultSetType, resultSetConcurrency); + } + + public Map> getTypeMap() throws SQLException { + return delegate.getTypeMap(); + } + + public void setTypeMap(Map> map) throws SQLException { + delegate.setTypeMap(map); + } + + public void setHoldability(int holdability) throws SQLException { + delegate.setHoldability(holdability); + } + + public int getHoldability() throws SQLException { + return delegate.getHoldability(); + } + + public Savepoint setSavepoint() throws SQLException { + return delegate.setSavepoint(); + } + + public Savepoint setSavepoint(String name) throws SQLException { + return delegate.setSavepoint(name); + } + + public void rollback(Savepoint savepoint) throws SQLException { + delegate.rollback(savepoint); + } + + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + delegate.releaseSavepoint(savepoint); + } + + public Statement createStatement(int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); + } + + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + return delegate.prepareStatement(sql, autoGeneratedKeys); + } + + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return delegate.prepareStatement(sql, columnIndexes); + } + + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { + return delegate.prepareStatement(sql, columnNames); + } + + public Clob createClob() throws SQLException { + return delegate.createClob(); + } + + public Blob createBlob() throws SQLException { + return delegate.createBlob(); + } + + public NClob createNClob() throws SQLException { + return delegate.createNClob(); + } + + public SQLXML createSQLXML() throws SQLException { + return delegate.createSQLXML(); + } + + public boolean isValid(int timeout) throws SQLException { + return delegate.isValid(timeout); + } + + public void setClientInfo(String name, String value) throws SQLClientInfoException { + delegate.setClientInfo(name, value); + } + + public void setClientInfo(Properties properties) throws SQLClientInfoException { + delegate.setClientInfo(properties); + } + + public String getClientInfo(String name) throws SQLException { + return delegate.getClientInfo(name); + } + + public Properties getClientInfo() throws SQLException { + return delegate.getClientInfo(); + } + + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return delegate.createArrayOf(typeName, elements); + } + + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return delegate.createStruct(typeName, attributes); + } + + public T unwrap(Class iface) throws SQLException { + return delegate.unwrap(iface); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return delegate.isWrapperFor(iface); + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/jdbc/PreparedStatementDelegator.java b/src/main/java/com/avaje/ebeaninternal/jdbc/PreparedStatementDelegator.java index cef11ab53..47295e583 100644 --- a/src/main/java/com/avaje/ebeaninternal/jdbc/PreparedStatementDelegator.java +++ b/src/main/java/com/avaje/ebeaninternal/jdbc/PreparedStatementDelegator.java @@ -1,435 +1,435 @@ -package com.avaje.ebeaninternal.jdbc; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.Date; -import java.sql.NClob; -import java.sql.ParameterMetaData; -import java.sql.PreparedStatement; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.Calendar; - -public class PreparedStatementDelegator implements PreparedStatement { - - private final PreparedStatement delegate; - - public PreparedStatementDelegator(PreparedStatement delegate) { - this.delegate = delegate; - } - - @Override - public void closeOnCompletion() throws SQLException { - delegate.closeOnCompletion(); - } - - @Override - public boolean isCloseOnCompletion() throws SQLException { - return delegate.isCloseOnCompletion(); - } - - public ResultSet executeQuery() throws SQLException { - return delegate.executeQuery(); - } - - public int executeUpdate() throws SQLException { - return delegate.executeUpdate(); - } - - public void setNull(int parameterIndex, int sqlType) throws SQLException { - delegate.setNull(parameterIndex, sqlType); - } - - public void setBoolean(int parameterIndex, boolean x) throws SQLException { - delegate.setBoolean(parameterIndex, x); - } - - public void setByte(int parameterIndex, byte x) throws SQLException { - delegate.setByte(parameterIndex, x); - } - - public void setShort(int parameterIndex, short x) throws SQLException { - delegate.setShort(parameterIndex, x); - } - - public void setInt(int parameterIndex, int x) throws SQLException { - delegate.setInt(parameterIndex, x); - } - - public void setLong(int parameterIndex, long x) throws SQLException { - delegate.setLong(parameterIndex, x); - } - - public void setFloat(int parameterIndex, float x) throws SQLException { - delegate.setFloat(parameterIndex, x); - } - - public void setDouble(int parameterIndex, double x) throws SQLException { - delegate.setDouble(parameterIndex, x); - } - - public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { - delegate.setBigDecimal(parameterIndex, x); - } - - public void setString(int parameterIndex, String x) throws SQLException { - delegate.setString(parameterIndex, x); - } - - public void setBytes(int parameterIndex, byte[] x) throws SQLException { - delegate.setBytes(parameterIndex, x); - } - - public void setDate(int parameterIndex, Date x) throws SQLException { - delegate.setDate(parameterIndex, x); - } - - public void setTime(int parameterIndex, Time x) throws SQLException { - delegate.setTime(parameterIndex, x); - } - - public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { - delegate.setTimestamp(parameterIndex, x); - } - - public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { - delegate.setAsciiStream(parameterIndex, x, length); - } - - @SuppressWarnings("deprecation") - public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { - delegate.setUnicodeStream(parameterIndex, x, length); - } - - public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { - delegate.setBinaryStream(parameterIndex, x, length); - } - - public void clearParameters() throws SQLException { - delegate.clearParameters(); - } - - public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { - delegate.setObject(parameterIndex, x, targetSqlType); - } - - public void setObject(int parameterIndex, Object x) throws SQLException { - delegate.setObject(parameterIndex, x); - } - - public boolean execute() throws SQLException { - return delegate.execute(); - } - - public void addBatch() throws SQLException { - delegate.addBatch(); - } - - public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { - delegate.setCharacterStream(parameterIndex, reader, length); - } - - public void setRef(int parameterIndex, Ref x) throws SQLException { - delegate.setRef(parameterIndex, x); - } - - public void setBlob(int parameterIndex, Blob x) throws SQLException { - delegate.setBlob(parameterIndex, x); - } - - public void setClob(int parameterIndex, Clob x) throws SQLException { - delegate.setClob(parameterIndex, x); - } - - public void setArray(int parameterIndex, Array x) throws SQLException { - delegate.setArray(parameterIndex, x); - } - - public ResultSetMetaData getMetaData() throws SQLException { - return delegate.getMetaData(); - } - - public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { - delegate.setDate(parameterIndex, x, cal); - } - - public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { - delegate.setTime(parameterIndex, x, cal); - } - - public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { - delegate.setTimestamp(parameterIndex, x, cal); - } - - public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { - delegate.setNull(parameterIndex, sqlType, typeName); - } - - public void setURL(int parameterIndex, URL x) throws SQLException { - delegate.setURL(parameterIndex, x); - } - - public ParameterMetaData getParameterMetaData() throws SQLException { - return delegate.getParameterMetaData(); - } - - public void setRowId(int parameterIndex, RowId x) throws SQLException { - delegate.setRowId(parameterIndex, x); - } - - public void setNString(int parameterIndex, String value) throws SQLException { - delegate.setNString(parameterIndex, value); - } - - public void setNCharacterStream(int parameterIndex, Reader value, long length) - throws SQLException { - delegate.setNCharacterStream(parameterIndex, value, length); - } - - public void setNClob(int parameterIndex, NClob value) throws SQLException { - delegate.setNClob(parameterIndex, value); - } - - public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { - delegate.setClob(parameterIndex, reader, length); - } - - public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { - delegate.setBlob(parameterIndex, inputStream, length); - } - - public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { - delegate.setNClob(parameterIndex, reader, length); - } - - public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { - delegate.setSQLXML(parameterIndex, xmlObject); - } - - public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) - throws SQLException { - delegate.setObject(parameterIndex, x, targetSqlType, scaleOrLength); - } - - public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { - delegate.setAsciiStream(parameterIndex, x, length); - } - - public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { - delegate.setBinaryStream(parameterIndex, x, length); - } - - public void setCharacterStream(int parameterIndex, Reader reader, long length) - throws SQLException { - delegate.setCharacterStream(parameterIndex, reader, length); - } - - public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { - delegate.setAsciiStream(parameterIndex, x); - } - - public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { - delegate.setBinaryStream(parameterIndex, x); - } - - public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { - delegate.setCharacterStream(parameterIndex, reader); - } - - public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - delegate.setNCharacterStream(parameterIndex, value); - } - - public void setClob(int parameterIndex, Reader reader) throws SQLException { - delegate.setClob(parameterIndex, reader); - } - - public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { - delegate.setBlob(parameterIndex, inputStream); - } - - public void setNClob(int parameterIndex, Reader reader) throws SQLException { - delegate.setNClob(parameterIndex, reader); - } - - public ResultSet executeQuery(String sql) throws SQLException { - return delegate.executeQuery(sql); - } - - public int executeUpdate(String sql) throws SQLException { - return delegate.executeUpdate(sql); - } - - public void close() throws SQLException { - delegate.close(); - } - - public int getMaxFieldSize() throws SQLException { - return delegate.getMaxFieldSize(); - } - - public void setMaxFieldSize(int max) throws SQLException { - delegate.setMaxFieldSize(max); - } - - public int getMaxRows() throws SQLException { - return delegate.getMaxRows(); - } - - public void setMaxRows(int max) throws SQLException { - delegate.setMaxRows(max); - } - - public void setEscapeProcessing(boolean enable) throws SQLException { - delegate.setEscapeProcessing(enable); - } - - public int getQueryTimeout() throws SQLException { - return delegate.getQueryTimeout(); - } - - public void setQueryTimeout(int seconds) throws SQLException { - delegate.setQueryTimeout(seconds); - } - - public void cancel() throws SQLException { - delegate.cancel(); - } - - public SQLWarning getWarnings() throws SQLException { - return delegate.getWarnings(); - } - - public void clearWarnings() throws SQLException { - delegate.clearWarnings(); - } - - public void setCursorName(String name) throws SQLException { - delegate.setCursorName(name); - } - - public boolean execute(String sql) throws SQLException { - return delegate.execute(sql); - } - - public ResultSet getResultSet() throws SQLException { - return delegate.getResultSet(); - } - - public int getUpdateCount() throws SQLException { - return delegate.getUpdateCount(); - } - - public boolean getMoreResults() throws SQLException { - return delegate.getMoreResults(); - } - - public void setFetchDirection(int direction) throws SQLException { - delegate.setFetchDirection(direction); - } - - public int getFetchDirection() throws SQLException { - return delegate.getFetchDirection(); - } - - public void setFetchSize(int rows) throws SQLException { - delegate.setFetchSize(rows); - } - - public int getFetchSize() throws SQLException { - return delegate.getFetchSize(); - } - - public int getResultSetConcurrency() throws SQLException { - return delegate.getResultSetConcurrency(); - } - - public int getResultSetType() throws SQLException { - return delegate.getResultSetType(); - } - - public void addBatch(String sql) throws SQLException { - delegate.addBatch(sql); - } - - public void clearBatch() throws SQLException { - delegate.clearBatch(); - } - - public int[] executeBatch() throws SQLException { - return delegate.executeBatch(); - } - - public Connection getConnection() throws SQLException { - return delegate.getConnection(); - } - - public boolean getMoreResults(int current) throws SQLException { - return delegate.getMoreResults(current); - } - - public ResultSet getGeneratedKeys() throws SQLException { - return delegate.getGeneratedKeys(); - } - - public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { - return delegate.executeUpdate(sql, autoGeneratedKeys); - } - - public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { - return delegate.executeUpdate(sql, columnIndexes); - } - - public int executeUpdate(String sql, String[] columnNames) throws SQLException { - return delegate.executeUpdate(sql, columnNames); - } - - public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { - return delegate.execute(sql, autoGeneratedKeys); - } - - public boolean execute(String sql, int[] columnIndexes) throws SQLException { - return delegate.execute(sql, columnIndexes); - } - - public boolean execute(String sql, String[] columnNames) throws SQLException { - return delegate.execute(sql, columnNames); - } - - public int getResultSetHoldability() throws SQLException { - return delegate.getResultSetHoldability(); - } - - public boolean isClosed() throws SQLException { - return delegate.isClosed(); - } - - public void setPoolable(boolean poolable) throws SQLException { - delegate.setPoolable(poolable); - } - - public boolean isPoolable() throws SQLException { - return delegate.isPoolable(); - } - - public T unwrap(Class iface) throws SQLException { - return delegate.unwrap(iface); - } - - public boolean isWrapperFor(Class iface) throws SQLException { - return delegate.isWrapperFor(iface); - } -} +package com.avaje.ebeaninternal.jdbc; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.NClob; +import java.sql.ParameterMetaData; +import java.sql.PreparedStatement; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; + +public class PreparedStatementDelegator implements PreparedStatement { + + private final PreparedStatement delegate; + + public PreparedStatementDelegator(PreparedStatement delegate) { + this.delegate = delegate; + } + + @Override + public void closeOnCompletion() throws SQLException { + delegate.closeOnCompletion(); + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + return delegate.isCloseOnCompletion(); + } + + public ResultSet executeQuery() throws SQLException { + return delegate.executeQuery(); + } + + public int executeUpdate() throws SQLException { + return delegate.executeUpdate(); + } + + public void setNull(int parameterIndex, int sqlType) throws SQLException { + delegate.setNull(parameterIndex, sqlType); + } + + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + delegate.setBoolean(parameterIndex, x); + } + + public void setByte(int parameterIndex, byte x) throws SQLException { + delegate.setByte(parameterIndex, x); + } + + public void setShort(int parameterIndex, short x) throws SQLException { + delegate.setShort(parameterIndex, x); + } + + public void setInt(int parameterIndex, int x) throws SQLException { + delegate.setInt(parameterIndex, x); + } + + public void setLong(int parameterIndex, long x) throws SQLException { + delegate.setLong(parameterIndex, x); + } + + public void setFloat(int parameterIndex, float x) throws SQLException { + delegate.setFloat(parameterIndex, x); + } + + public void setDouble(int parameterIndex, double x) throws SQLException { + delegate.setDouble(parameterIndex, x); + } + + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + delegate.setBigDecimal(parameterIndex, x); + } + + public void setString(int parameterIndex, String x) throws SQLException { + delegate.setString(parameterIndex, x); + } + + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + delegate.setBytes(parameterIndex, x); + } + + public void setDate(int parameterIndex, Date x) throws SQLException { + delegate.setDate(parameterIndex, x); + } + + public void setTime(int parameterIndex, Time x) throws SQLException { + delegate.setTime(parameterIndex, x); + } + + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + delegate.setTimestamp(parameterIndex, x); + } + + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + delegate.setAsciiStream(parameterIndex, x, length); + } + + @SuppressWarnings("deprecation") + public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { + delegate.setUnicodeStream(parameterIndex, x, length); + } + + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + delegate.setBinaryStream(parameterIndex, x, length); + } + + public void clearParameters() throws SQLException { + delegate.clearParameters(); + } + + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + delegate.setObject(parameterIndex, x, targetSqlType); + } + + public void setObject(int parameterIndex, Object x) throws SQLException { + delegate.setObject(parameterIndex, x); + } + + public boolean execute() throws SQLException { + return delegate.execute(); + } + + public void addBatch() throws SQLException { + delegate.addBatch(); + } + + public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { + delegate.setCharacterStream(parameterIndex, reader, length); + } + + public void setRef(int parameterIndex, Ref x) throws SQLException { + delegate.setRef(parameterIndex, x); + } + + public void setBlob(int parameterIndex, Blob x) throws SQLException { + delegate.setBlob(parameterIndex, x); + } + + public void setClob(int parameterIndex, Clob x) throws SQLException { + delegate.setClob(parameterIndex, x); + } + + public void setArray(int parameterIndex, Array x) throws SQLException { + delegate.setArray(parameterIndex, x); + } + + public ResultSetMetaData getMetaData() throws SQLException { + return delegate.getMetaData(); + } + + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + delegate.setDate(parameterIndex, x, cal); + } + + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + delegate.setTime(parameterIndex, x, cal); + } + + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + delegate.setTimestamp(parameterIndex, x, cal); + } + + public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { + delegate.setNull(parameterIndex, sqlType, typeName); + } + + public void setURL(int parameterIndex, URL x) throws SQLException { + delegate.setURL(parameterIndex, x); + } + + public ParameterMetaData getParameterMetaData() throws SQLException { + return delegate.getParameterMetaData(); + } + + public void setRowId(int parameterIndex, RowId x) throws SQLException { + delegate.setRowId(parameterIndex, x); + } + + public void setNString(int parameterIndex, String value) throws SQLException { + delegate.setNString(parameterIndex, value); + } + + public void setNCharacterStream(int parameterIndex, Reader value, long length) + throws SQLException { + delegate.setNCharacterStream(parameterIndex, value, length); + } + + public void setNClob(int parameterIndex, NClob value) throws SQLException { + delegate.setNClob(parameterIndex, value); + } + + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + delegate.setClob(parameterIndex, reader, length); + } + + public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { + delegate.setBlob(parameterIndex, inputStream, length); + } + + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + delegate.setNClob(parameterIndex, reader, length); + } + + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + delegate.setSQLXML(parameterIndex, xmlObject); + } + + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) + throws SQLException { + delegate.setObject(parameterIndex, x, targetSqlType, scaleOrLength); + } + + public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { + delegate.setAsciiStream(parameterIndex, x, length); + } + + public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { + delegate.setBinaryStream(parameterIndex, x, length); + } + + public void setCharacterStream(int parameterIndex, Reader reader, long length) + throws SQLException { + delegate.setCharacterStream(parameterIndex, reader, length); + } + + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + delegate.setAsciiStream(parameterIndex, x); + } + + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + delegate.setBinaryStream(parameterIndex, x); + } + + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + delegate.setCharacterStream(parameterIndex, reader); + } + + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + delegate.setNCharacterStream(parameterIndex, value); + } + + public void setClob(int parameterIndex, Reader reader) throws SQLException { + delegate.setClob(parameterIndex, reader); + } + + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + delegate.setBlob(parameterIndex, inputStream); + } + + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + delegate.setNClob(parameterIndex, reader); + } + + public ResultSet executeQuery(String sql) throws SQLException { + return delegate.executeQuery(sql); + } + + public int executeUpdate(String sql) throws SQLException { + return delegate.executeUpdate(sql); + } + + public void close() throws SQLException { + delegate.close(); + } + + public int getMaxFieldSize() throws SQLException { + return delegate.getMaxFieldSize(); + } + + public void setMaxFieldSize(int max) throws SQLException { + delegate.setMaxFieldSize(max); + } + + public int getMaxRows() throws SQLException { + return delegate.getMaxRows(); + } + + public void setMaxRows(int max) throws SQLException { + delegate.setMaxRows(max); + } + + public void setEscapeProcessing(boolean enable) throws SQLException { + delegate.setEscapeProcessing(enable); + } + + public int getQueryTimeout() throws SQLException { + return delegate.getQueryTimeout(); + } + + public void setQueryTimeout(int seconds) throws SQLException { + delegate.setQueryTimeout(seconds); + } + + public void cancel() throws SQLException { + delegate.cancel(); + } + + public SQLWarning getWarnings() throws SQLException { + return delegate.getWarnings(); + } + + public void clearWarnings() throws SQLException { + delegate.clearWarnings(); + } + + public void setCursorName(String name) throws SQLException { + delegate.setCursorName(name); + } + + public boolean execute(String sql) throws SQLException { + return delegate.execute(sql); + } + + public ResultSet getResultSet() throws SQLException { + return delegate.getResultSet(); + } + + public int getUpdateCount() throws SQLException { + return delegate.getUpdateCount(); + } + + public boolean getMoreResults() throws SQLException { + return delegate.getMoreResults(); + } + + public void setFetchDirection(int direction) throws SQLException { + delegate.setFetchDirection(direction); + } + + public int getFetchDirection() throws SQLException { + return delegate.getFetchDirection(); + } + + public void setFetchSize(int rows) throws SQLException { + delegate.setFetchSize(rows); + } + + public int getFetchSize() throws SQLException { + return delegate.getFetchSize(); + } + + public int getResultSetConcurrency() throws SQLException { + return delegate.getResultSetConcurrency(); + } + + public int getResultSetType() throws SQLException { + return delegate.getResultSetType(); + } + + public void addBatch(String sql) throws SQLException { + delegate.addBatch(sql); + } + + public void clearBatch() throws SQLException { + delegate.clearBatch(); + } + + public int[] executeBatch() throws SQLException { + return delegate.executeBatch(); + } + + public Connection getConnection() throws SQLException { + return delegate.getConnection(); + } + + public boolean getMoreResults(int current) throws SQLException { + return delegate.getMoreResults(current); + } + + public ResultSet getGeneratedKeys() throws SQLException { + return delegate.getGeneratedKeys(); + } + + public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + return delegate.executeUpdate(sql, autoGeneratedKeys); + } + + public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { + return delegate.executeUpdate(sql, columnIndexes); + } + + public int executeUpdate(String sql, String[] columnNames) throws SQLException { + return delegate.executeUpdate(sql, columnNames); + } + + public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { + return delegate.execute(sql, autoGeneratedKeys); + } + + public boolean execute(String sql, int[] columnIndexes) throws SQLException { + return delegate.execute(sql, columnIndexes); + } + + public boolean execute(String sql, String[] columnNames) throws SQLException { + return delegate.execute(sql, columnNames); + } + + public int getResultSetHoldability() throws SQLException { + return delegate.getResultSetHoldability(); + } + + public boolean isClosed() throws SQLException { + return delegate.isClosed(); + } + + public void setPoolable(boolean poolable) throws SQLException { + delegate.setPoolable(poolable); + } + + public boolean isPoolable() throws SQLException { + return delegate.isPoolable(); + } + + public T unwrap(Class iface) throws SQLException { + return delegate.unwrap(iface); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return delegate.isWrapperFor(iface); + } +} diff --git a/src/main/java/com/avaje/ebeaninternal/util/FilterExpressionList.java b/src/main/java/com/avaje/ebeaninternal/util/FilterExpressionList.java index 32d92df6d..5f9316b89 100644 --- a/src/main/java/com/avaje/ebeaninternal/util/FilterExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/util/FilterExpressionList.java @@ -1,154 +1,154 @@ -package com.avaje.ebeaninternal.util; - -import com.avaje.ebean.*; -import com.avaje.ebeaninternal.api.SpiExpressionList; -import com.avaje.ebeaninternal.server.expression.FilterExprPath; - -import javax.persistence.PersistenceException; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class FilterExpressionList extends DefaultExpressionList { - - private static final long serialVersionUID = 2226895827150099020L; - - private final Query rootQuery; - - private final FilterExprPath pathPrefix; - - public FilterExpressionList(FilterExprPath pathPrefix, FilterExpressionList original) { - super(null, original.expr, null, original.getUnderlyingList()); - this.pathPrefix = pathPrefix; - this.rootQuery = original.rootQuery; - } - - public FilterExpressionList(FilterExprPath pathPrefix, ExpressionFactory expr, Query rootQuery) { - super(null, expr, null); - this.pathPrefix = pathPrefix; - this.rootQuery = rootQuery; - } - - @Override - public SpiExpressionList trimPath(int prefixTrim) { - return new FilterExpressionList(pathPrefix.trimPath(prefixTrim), this); - } - - public FilterExprPath getPathPrefix() { - return pathPrefix; - } - - private String notAllowedMessage = "This method is not allowed on a filter"; - - @Override - public ExpressionList filterMany(String prop) { - return rootQuery.filterMany(prop); - } - - @Override - public FutureIds findFutureIds() { - return rootQuery.findFutureIds(); - } - - @Override - public FutureList findFutureList() { - return rootQuery.findFutureList(); - } - - @Override - public FutureRowCount findFutureRowCount() { - return rootQuery.findFutureRowCount(); - } - - @Override - public List findList() { - return rootQuery.findList(); - } - - @Override - public Map findMap() { - return rootQuery.findMap(); - } - - @Override - public int findRowCount() { - return rootQuery.findRowCount(); - } - - @Override - public Set findSet() { - return rootQuery.findSet(); - } - - @Override - public T findUnique() { - return rootQuery.findUnique(); - } - - @Override - public ExpressionList having() { - throw new PersistenceException(notAllowedMessage); - } - - @Override - public ExpressionList idEq(Object value) { - throw new PersistenceException(notAllowedMessage); - } - - @Override - public ExpressionList idIn(List idValues) { - throw new PersistenceException(notAllowedMessage); - } - - @Override - public OrderBy order() { - return rootQuery.order(); - } - - @Override - public Query order(String orderByClause) { - return rootQuery.order(orderByClause); - } - - @Override - public Query orderBy(String orderBy) { - return rootQuery.orderBy(orderBy); - } - - @Override - public Query query() { - return rootQuery; - } - - @Override - public Query select(String properties) { - throw new PersistenceException(notAllowedMessage); - } - - @Override - public Query setFirstRow(int firstRow) { - return rootQuery.setFirstRow(firstRow); - } - - @Override - public Query setMapKey(String mapKey) { - return rootQuery.setMapKey(mapKey); - } - - @Override - public Query setMaxRows(int maxRows) { - return rootQuery.setMaxRows(maxRows); - } - - @Override - public Query setUseCache(boolean useCache) { - return rootQuery.setUseCache(useCache); - } - - @Override - public ExpressionList where() { - return rootQuery.where(); - } - - -} +package com.avaje.ebeaninternal.util; + +import com.avaje.ebean.*; +import com.avaje.ebeaninternal.api.SpiExpressionList; +import com.avaje.ebeaninternal.server.expression.FilterExprPath; + +import javax.persistence.PersistenceException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class FilterExpressionList extends DefaultExpressionList { + + private static final long serialVersionUID = 2226895827150099020L; + + private final Query rootQuery; + + private final FilterExprPath pathPrefix; + + public FilterExpressionList(FilterExprPath pathPrefix, FilterExpressionList original) { + super(null, original.expr, null, original.getUnderlyingList()); + this.pathPrefix = pathPrefix; + this.rootQuery = original.rootQuery; + } + + public FilterExpressionList(FilterExprPath pathPrefix, ExpressionFactory expr, Query rootQuery) { + super(null, expr, null); + this.pathPrefix = pathPrefix; + this.rootQuery = rootQuery; + } + + @Override + public SpiExpressionList trimPath(int prefixTrim) { + return new FilterExpressionList(pathPrefix.trimPath(prefixTrim), this); + } + + public FilterExprPath getPathPrefix() { + return pathPrefix; + } + + private String notAllowedMessage = "This method is not allowed on a filter"; + + @Override + public ExpressionList filterMany(String prop) { + return rootQuery.filterMany(prop); + } + + @Override + public FutureIds findFutureIds() { + return rootQuery.findFutureIds(); + } + + @Override + public FutureList findFutureList() { + return rootQuery.findFutureList(); + } + + @Override + public FutureRowCount findFutureRowCount() { + return rootQuery.findFutureRowCount(); + } + + @Override + public List findList() { + return rootQuery.findList(); + } + + @Override + public Map findMap() { + return rootQuery.findMap(); + } + + @Override + public int findRowCount() { + return rootQuery.findRowCount(); + } + + @Override + public Set findSet() { + return rootQuery.findSet(); + } + + @Override + public T findUnique() { + return rootQuery.findUnique(); + } + + @Override + public ExpressionList having() { + throw new PersistenceException(notAllowedMessage); + } + + @Override + public ExpressionList idEq(Object value) { + throw new PersistenceException(notAllowedMessage); + } + + @Override + public ExpressionList idIn(List idValues) { + throw new PersistenceException(notAllowedMessage); + } + + @Override + public OrderBy order() { + return rootQuery.order(); + } + + @Override + public Query order(String orderByClause) { + return rootQuery.order(orderByClause); + } + + @Override + public Query orderBy(String orderBy) { + return rootQuery.orderBy(orderBy); + } + + @Override + public Query query() { + return rootQuery; + } + + @Override + public Query select(String properties) { + throw new PersistenceException(notAllowedMessage); + } + + @Override + public Query setFirstRow(int firstRow) { + return rootQuery.setFirstRow(firstRow); + } + + @Override + public Query setMapKey(String mapKey) { + return rootQuery.setMapKey(mapKey); + } + + @Override + public Query setMaxRows(int maxRows) { + return rootQuery.setMaxRows(maxRows); + } + + @Override + public Query setUseCache(boolean useCache) { + return rootQuery.setUseCache(useCache); + } + + @Override + public ExpressionList where() { + return rootQuery.where(); + } + + +}