diff --git a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java index c1de039bd..95d82e27e 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BeanIdList.java @@ -7,40 +7,40 @@ import java.util.List; */ public class BeanIdList { - private final List idList; + private final List idList; private boolean hasMore; - public BeanIdList(List idList) { - this.idList = idList; - } + public BeanIdList(List idList) { + this.idList = idList; + } - /** - * Add an Id to the list. - */ - public void add(Object id){ - idList.add(id); - } + /** + * 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 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; - } + /** + * 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; - } + /** + * 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 ecb4c4afe..c2d0a82eb 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/BindParams.java +++ b/src/main/java/com/avaje/ebeaninternal/api/BindParams.java @@ -1,5 +1,7 @@ package com.avaje.ebeaninternal.api; +import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -8,8 +10,6 @@ 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. *

@@ -18,18 +18,18 @@ import com.avaje.ebeaninternal.server.querydefn.NaturalKeyBindParam; */ public class BindParams implements Serializable { - private static final long serialVersionUID = 4541081933302086285L; + private static final long serialVersionUID = 4541081933302086285L; - private final List positionedParameters = new ArrayList<>(); + private final List positionedParameters = new ArrayList<>(); - private final Map namedParameters = new LinkedHashMap<>(); + private final 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; + /** + * 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 @@ -37,16 +37,16 @@ public class BindParams implements Serializable { */ private int[] bindHash; - public BindParams() { - } + public BindParams() { + } public int queryBindHash() { - int hc = namedParameters.hashCode(); + int hc = namedParameters.hashCode(); for (Param positionedParameter : positionedParameters) { hc = hc * 31 + positionedParameter.hashCode(); } - return hc; - } + return hc; + } /** * Return the hash that should be included with the query plan. @@ -84,136 +84,136 @@ public class BindParams implements Serializable { 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()) { + /** + * 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 copy; + } - /** - * Return true if there are no bind parameters. - */ - public boolean isEmpty() { - return positionedParameters.isEmpty() && namedParameters.isEmpty(); - } + /** + * 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; - } + /** + * 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(); - } + 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(); - } + /** + * 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 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) { + /** + * 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); - } + 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) { + /** + * 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); - } + 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); - } + /** + * 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(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); - } + 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) { + /** + * 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); - } + 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 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) { + /** + * 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; - } + Param p = getParam(name); + p.setInValue(value); + return p; + } /** * Set an encryption key as a bind value. @@ -227,50 +227,50 @@ public class BindParams implements Serializable { return p; } - /** - * Register the named parameter as an Out parameter. - */ - public void registerOut(String name, int outType) { - Param p = getParam(name); - p.setOutType(outType); - } + /** + * 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 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 named parameter. + */ + public Param getParameter(String name) { + return getParam(name); + } - /** - * Return the values of ordered parameters. - */ - public List positionedParameters() { - return positionedParameters; - } + /** + * 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; - } + /** + * 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 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. @@ -295,160 +295,160 @@ public class BindParams implements Serializable { } /** - * 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 { + * 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 List paramList; - private final StringBuilder preparedSql; + private final StringBuilder preparedSql; - public OrderedList() { - this(new ArrayList<>()); - } + public OrderedList() { + this(new ArrayList<>()); + } - public OrderedList(List paramList) { - this.paramList = paramList; - this.preparedSql = new StringBuilder(); - } + 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); - } + /** + * 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(); - } + /** + * 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; - } + /** + * 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); - } + /** + * Append parsedSql that has named parameters converted into ?. + */ + public void appendSql(String parsedSql) { + preparedSql.append(parsedSql); + } - public String getPreparedSql() { - return preparedSql.toString(); - } - } + public String getPreparedSql() { + return preparedSql.toString(); + } + } - /** - * A In Out capable parameter for the CallableStatement. - */ - public static final class Param implements Serializable { + /** + * 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 isInParam; - private boolean isOutParam; + private boolean isOutParam; - private int type; + private int type; - private Object inValue; + private Object inValue; - private Object outValue; + private Object outValue; - /** - * Construct a Parameter. - */ - public Param() { - } + /** + * Construct a Parameter. + */ + public Param() { + } - public int queryBindCount() { - if (inValue == null) { - return 0; - } - if (inValue instanceof Collection){ - return ((Collection)inValue).size(); - } - return 1; - } + 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; - } + /** + * 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 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) { + 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 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 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; - } + /** + * 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 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 the In value. + */ + public void setInValue(Object in) { + this.inValue = in; + this.isInParam = true; + } /** * Set an encryption key (which can not be logged). @@ -459,39 +459,39 @@ public class BindParams implements Serializable { 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; - } + /** + * 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 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; - } + /** + * 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; - } + /** + * 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. @@ -500,5 +500,5 @@ public class BindParams implements Serializable { 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 8e3f0679e..aac90be4c 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ClassUtil.java @@ -44,7 +44,7 @@ public class ClassUtil { ClassLoader contextLoader() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); - return (loader != null) ? loader: callerLoader; + return (loader != null) ? loader : callerLoader; } public Class forName(String name) throws ClassNotFoundException { diff --git a/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java b/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java index 2fc8613f7..5de101008 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ConcurrencyMode.java @@ -5,13 +5,13 @@ package com.avaje.ebeaninternal.api; */ public enum ConcurrencyMode { - /** - * No concurrency checking. - */ - NONE, - - /** - * Use a version column. - */ - VERSION + /** + * No concurrency checking. + */ + NONE, + + /** + * Use a version column. + */ + VERSION } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java b/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java index a9422ac14..c885b29e2 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQuery.java @@ -6,7 +6,7 @@ package com.avaje.ebeaninternal.api; public class HashQuery { private final CQueryPlanKey planHash; - + private final int bindHash; /** @@ -26,7 +26,7 @@ public class HashQuery { hc = 31 * hc + bindHash; return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -34,7 +34,7 @@ public class HashQuery { if (!(obj instanceof HashQuery)) { return false; } - + HashQuery e = (HashQuery) obj; return e.bindHash == bindHash && e.planHash.equals(planHash); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java index d4c75e05d..d7faa080f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlan.java @@ -6,9 +6,9 @@ package com.avaje.ebeaninternal.api; public class HashQueryPlan { private final String rawSql; - + private final int planHash; - + private final int bindCount; public HashQueryPlan(String rawSql, int planHash, int bindCount) { @@ -18,7 +18,7 @@ public class HashQueryPlan { } public String toString() { - return planHash+":"+bindCount+(rawSql != null ? ":r" : ""); + return planHash + ":" + bindCount + (rawSql != null ? ":r" : ""); } /** @@ -27,7 +27,7 @@ public class HashQueryPlan { * can be used as a shot form proxy for the actual sql. */ public String getPartialKey() { - return planHash+"_"+bindCount; + return planHash + "_" + bindCount; } public int hashCode() { @@ -36,7 +36,7 @@ public class HashQueryPlan { hc = hc * 31 + (rawSql == null ? 0 : rawSql.hashCode()); return hc; } - + public boolean equals(Object obj) { if (obj == this) { return true; @@ -44,11 +44,11 @@ public class HashQueryPlan { if (!(obj instanceof HashQueryPlan)) { return false; } - + HashQueryPlan e = (HashQueryPlan) obj; //noinspection StringEquality return e.planHash == planHash - && e.bindCount == bindCount - && ((e.rawSql == rawSql) || (e.rawSql != null && e.rawSql.equals(rawSql))); + && e.bindCount == bindCount + && ((e.rawSql == rawSql) || (e.rawSql != null && e.rawSql.equals(rawSql))); } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java index c1f2ad696..e55962625 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HashQueryPlanBuilder.java @@ -8,7 +8,7 @@ import java.util.Set; public class HashQueryPlanBuilder { private int planHash; - + private int bindCount; public HashQueryPlanBuilder() { @@ -16,9 +16,9 @@ public class HashQueryPlanBuilder { } public String toString() { - return planHash+":"+bindCount; + return planHash + ":" + bindCount; } - + /** * Add a class to the hash calculation. */ @@ -57,7 +57,7 @@ public class HashQueryPlanBuilder { planHash = planHash * 92821 + (hashValue); return this; } - + /** * Add a boolean to the hash calculation. */ @@ -65,7 +65,7 @@ public class HashQueryPlanBuilder { planHash = planHash * 92821 + (booleanValue ? 92821 : 0); return this; } - + /** * Add a number to the bind count for the hash. */ @@ -83,7 +83,7 @@ public class HashQueryPlanBuilder { * Build and return the calculated HashQueryPlan. */ public String build() { - return planHash+"_"+bindCount; + return planHash + "_" + bindCount; } public int getPlanHash() { diff --git a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java index abc111d61..2c7978171 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/HelpScopeTrans.java @@ -9,28 +9,29 @@ import com.avaje.ebean.TxScope; */ 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); - } + /** + * 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/LoadBeanBuffer.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java index 82e26aa9b..4a90fefa9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanBuffer.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.util.List; - import com.avaje.ebean.bean.EntityBeanIntercept; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; +import java.util.List; + /** * A buffer of beans for batch lazy loading and secondary query loading. */ @@ -14,7 +14,7 @@ public interface LoadBeanBuffer { int getBatchSize(); List getBatch(); - + BeanDescriptor getBeanDescriptor(); PersistenceContext getPersistenceContext(); @@ -23,4 +23,4 @@ public interface LoadBeanBuffer { void configureQuery(SpiQuery query, String lazyLoadProperty); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java index f38b43189..65c9b0ffc 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadBeanContext.java @@ -5,6 +5,5 @@ 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/LoadManyBuffer.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java index d067559e9..f8d1a1ce3 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyBuffer.java @@ -1,13 +1,13 @@ package com.avaje.ebeaninternal.api; -import java.util.List; - import com.avaje.ebean.bean.BeanCollection; import com.avaje.ebean.bean.ObjectGraphNode; import com.avaje.ebean.bean.PersistenceContext; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany; +import java.util.List; + /** * A buffer of bean collections for batch lazy loading and secondary query loading. */ @@ -16,7 +16,7 @@ public interface LoadManyBuffer { int getBatchSize(); List> getBatch(); - + BeanPropertyAssocMany getBeanProperty(); ObjectGraphNode getObjectGraphNode(); @@ -30,4 +30,4 @@ public interface LoadManyBuffer { void configureQuery(SpiQuery query); boolean isUseDocStore(); -} \ No newline at end of file +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java index 4747778af..dd64d2bd9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyContext.java @@ -5,5 +5,5 @@ 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 3f6172422..281939151 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadManyRequest.java @@ -42,7 +42,7 @@ public class LoadManyRequest extends LoadRequest { this(loadContext, parentRequest, false, false, false); } - private LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { + private LoadManyRequest(LoadManyBuffer loadContext, OrmQueryRequest parentRequest, boolean lazy, boolean onlyIds, boolean loadCache) { super(parentRequest, lazy); this.loadContext = loadContext; this.batch = loadContext.getBatch(); diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java index 89c2c7fdf..4220a28f3 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadRequest.java @@ -14,12 +14,12 @@ public abstract class LoadRequest { protected final boolean lazy; - public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { + public LoadRequest(OrmQueryRequest parentRequest, boolean lazy) { - this.parentRequest = parentRequest; - this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); - this.lazy = lazy; - } + this.parentRequest = parentRequest; + this.transaction = parentRequest == null ? null : parentRequest.getTransaction(); + this.lazy = lazy; + } /** * Return the associated bean type for this load request. @@ -35,29 +35,29 @@ public abstract class LoadRequest { 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; - } + /** + * Return true if this is a lazy load and false if it is a secondary query. + */ + public boolean isLazy() { + return lazy; + } - /** - * Return true if the parent query is a findIterate() type query. - * So one of - findIterate(), findEach(), findEachWhile() or findVisit(). - */ - public boolean isParentFindIterate() { - return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE; - } + /** + * Return the transaction to use if this is a secondary query. + *

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

+ */ + public Transaction getTransaction() { + return transaction; + } + + /** + * Return true if the parent query is a findIterate() type query. + * So one of - findIterate(), findEach(), findEachWhile() or findVisit(). + */ + public boolean isParentFindIterate() { + return parentRequest != null && parentRequest.getQuery().getType() == SpiQuery.Type.ITERATE; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java index bb97cccca..317409f45 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/LoadSecondaryQuery.java @@ -11,8 +11,8 @@ import com.avaje.ebeaninternal.server.core.OrmQueryRequest; */ public interface LoadSecondaryQuery { - /** - * Execute the secondary query with a given batch size. - */ - void loadSecondaryQuery(OrmQueryRequest parentRequest, boolean forEach); + /** + * Execute the secondary query with a given batch size. + */ + void loadSecondaryQuery(OrmQueryRequest parentRequest, boolean forEach); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java index 3a2e8221c..86aac0370 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/Monitor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/Monitor.java @@ -7,6 +7,6 @@ import java.io.Serializable; */ public class Monitor implements Serializable { - private static final long serialVersionUID = -2741687226680981940L; - + private static final long serialVersionUID = -2741687226680981940L; + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java b/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java index 2b183074c..0b9338ed9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java +++ b/src/main/java/com/avaje/ebeaninternal/api/PropertyJoin.java @@ -11,7 +11,7 @@ public class PropertyJoin { * The property name. */ private final String property; - + /** * Set to true if the property needs to be an outer join. */ @@ -35,5 +35,5 @@ public class PropertyJoin { public SqlJoinType getSqlJoinType() { return joinType; } - + } diff --git a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java index 0b437b36d..85bc3fd89 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/ScopedTransaction.java @@ -10,6 +10,7 @@ import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.BatchControl; + import javax.persistence.PersistenceException; import javax.persistence.RollbackException; import java.io.IOException; diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java b/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java index c4bf5f744..3619b9349 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiBackgroundExecutor.java @@ -7,8 +7,8 @@ import com.avaje.ebean.BackgroundExecutor; */ public interface SpiBackgroundExecutor extends BackgroundExecutor { - /** - * Shutdown any associated thread pools. - */ - void shutdown(); + /** + * Shutdown any associated thread pools. + */ + void shutdown(); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java b/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java index 152492c26..2afa43159 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiCallableSql.java @@ -4,7 +4,7 @@ import com.avaje.ebean.CallableSql; public interface SpiCallableSql extends CallableSql { - BindParams getBindParams(); - - TransactionEventTable getTransactionEventTable(); + BindParams getBindParams(); + + TransactionEventTable getTransactionEventTable(); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java index f375d7cab..09e02d717 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiEbeanServer.java @@ -13,10 +13,10 @@ import com.avaje.ebean.config.ServerConfig; import com.avaje.ebean.config.dbplatform.DatabasePlatform; import com.avaje.ebean.event.readaudit.ReadAuditLogger; import com.avaje.ebean.event.readaudit.ReadAuditPrepare; +import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.query.CQuery; import com.avaje.ebeaninternal.server.transaction.RemoteTransactionEvent; -import com.avaje.ebeaninternal.server.core.timezone.DataTimeZone; import java.util.List; diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java index 0c996e741..7195d79e7 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpression.java @@ -13,28 +13,28 @@ import java.io.IOException; */ public interface SpiExpression extends Expression { - /** - * Simplify nested expressions if possible. - */ - void simplify(); + /** + * Simplify nested expressions if possible. + */ + void simplify(); - /** + /** * Write the expression as an elastic search expression. */ void writeDocQuery(DocQueryContext context) throws IOException; - /** - * Return the nested path for this expression. - */ - String nestedPath(BeanDescriptor desc); + /** + * Return the nested path for this expression. + */ + String nestedPath(BeanDescriptor desc); - /** - * Process "Many" properties populating ManyWhereJoins. + /** + * Process "Many" properties populating ManyWhereJoins. *

* Predicates on Many properties require an extra independent join clause. *

*/ - void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins); + void containsMany(BeanDescriptor desc, ManyWhereJoins whereManyJoins); /** * Prepare the expression. For example, compile sub-query expressions etc. @@ -42,18 +42,18 @@ public interface SpiExpression extends Expression { void prepareExpression(BeanQueryRequest request); /** - * Calculate a hash value used to identify a query for AutoTune tuning. - *

- * That is, if the hash changes then the query will be considered different - * from an AutoTune perspective and get different tuning. - *

- */ - void queryPlanHash(HashQueryPlanBuilder builder); + * Calculate a hash value used to identify a query for AutoTune tuning. + *

+ * That is, if the hash changes then the query will be considered different + * from an AutoTune perspective and get different tuning. + *

+ */ + void queryPlanHash(HashQueryPlanBuilder builder); - /** - * Return the hash value for the values that will be bound. - */ - int queryBindHash(); + /** + * Return the hash value for the values that will be bound. + */ + int queryBindHash(); /** * Return true if the expression is the same without taking into account bind values. @@ -65,29 +65,28 @@ public interface SpiExpression extends Expression { */ boolean isSameByBind(SpiExpression other); - /** - * Add some sql to the query. - *

- * This will contain ? as a place holder for each associated bind values. - *

- *

- * The 'sql' added to the query can contain object property names rather - * than db tables and columns. This 'sql' is later parsed converting the - * logical property names to their full database column names. - *

- * @param request - * the associated request. - */ - void addSql(SpiExpressionRequest request); + /** + * Add some sql to the query. + *

+ * This will contain ? as a place holder for each associated bind values. + *

+ *

+ * The 'sql' added to the query can contain object property names rather + * than db tables and columns. This 'sql' is later parsed converting the + * logical property names to their full database column names. + *

+ * + * @param request the associated request. + */ + void addSql(SpiExpressionRequest request); - /** - * Add the parameter values to be set against query. For each ? place holder - * there should be a corresponding value that is added to the bindList. - * - * @param request - * the associated request. - */ - void addBindValues(SpiExpressionRequest request); + /** + * Add the parameter values to be set against query. For each ? place holder + * there should be a corresponding value that is added to the bindList. + * + * @param request the associated request. + */ + void addBindValues(SpiExpressionRequest request); /** * Validate all the properties/paths associated with this expression. @@ -99,8 +98,8 @@ public interface SpiExpression extends Expression { */ SpiExpression copyForPlanKey(); - /** - * Return the bind Id value if this is a "equal to" expression for the id property. + /** + * Return the bind Id value if this is a "equal to" expression for the id property. */ - Object getIdEqualTo(String idName); + Object getIdEqualTo(String idName); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java index 4c19c61a2..895b81203 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionList.java @@ -27,10 +27,10 @@ public interface SpiExpressionList extends ExpressionList, SpiExpression { */ SpiExpressionList trimPath(int prefixTrim); - /** - * Return true if this list is empty. - */ - boolean isEmpty(); + /** + * Return true if this list is empty. + */ + boolean isEmpty(); /** * Write the top level where expressions taking into account possible extra idEquals expression. diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java index 51a7f1c0e..99c81f2ec 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlQuery.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.api; -import java.sql.PreparedStatement; - import com.avaje.ebean.SqlQuery; /** diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java index 2060a9c9a..b19ce0b9d 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiSqlUpdate.java @@ -4,7 +4,7 @@ import com.avaje.ebean.SqlUpdate; public interface SpiSqlUpdate extends SqlUpdate { - BindParams getBindParams(); + BindParams getBindParams(); void setGeneratedSql(String sql); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java index 5224acf57..e63071432 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransaction.java @@ -9,6 +9,7 @@ import com.avaje.ebeaninternal.server.core.PersistDeferredRelationship; import com.avaje.ebeaninternal.server.core.PersistRequest; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.persist.BatchControl; + import java.sql.Connection; /** diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java b/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java index 881b32c49..32a316338 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiTransactionScopeManager.java @@ -2,5 +2,5 @@ package com.avaje.ebeaninternal.api; public interface SpiTransactionScopeManager { - void replace(SpiTransaction t); + void replace(SpiTransaction t); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java index 04d7be2b9..17324e507 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdate.java @@ -7,70 +7,70 @@ import com.avaje.ebean.Update; */ public interface SpiUpdate extends Update { - /** - * The type of the update request. - */ - enum OrmUpdateType { - INSERT { - public String toString() { - return "Insert"; - } - }, - UPDATE { - public String toString() { - return "Update"; - } - }, - DELETE { - public String toString() { - return "Delete"; - } - }, - UNKNOWN { - public String toString() { - return "Unknown"; - } + /** + * The type of the update request. + */ + enum OrmUpdateType { + INSERT { + public String toString() { + return "Insert"; + } + }, + UPDATE { + public String toString() { + return "Update"; + } + }, + DELETE { + public String toString() { + return "Delete"; + } + }, + UNKNOWN { + public String toString() { + return "Unknown"; + } - } - } - - /** - * Return the type of bean being updated. - */ - Class getBeanType(); + } + } - /** - * Return the type of this - insert, update or delete. - */ - OrmUpdateType getOrmUpdateType(); - - /** - * Return the name of the table being modified. - */ - String getBaseTable(); - - /** - * Return the update statement. This could be either sql or an orm update with bean types and property names. - */ - String getUpdateStatement(); - - /** - * Return the timeout in seconds. - */ - int getTimeout(); - - /** - * Return true if the cache should be notified to invalidate objects. - */ - boolean isNotifyCache(); - - /** - * Return the bind parameters. - */ - BindParams getBindParams(); - - /** - * Set the generated sql used. - */ - void setGeneratedSql(String sql); + /** + * Return the type of bean being updated. + */ + Class getBeanType(); + + /** + * Return the type of this - insert, update or delete. + */ + OrmUpdateType getOrmUpdateType(); + + /** + * Return the name of the table being modified. + */ + String getBaseTable(); + + /** + * Return the update statement. This could be either sql or an orm update with bean types and property names. + */ + String getUpdateStatement(); + + /** + * Return the timeout in seconds. + */ + int getTimeout(); + + /** + * Return true if the cache should be notified to invalidate objects. + */ + boolean isNotifyCache(); + + /** + * Return the bind parameters. + */ + BindParams getBindParams(); + + /** + * Set the generated sql used. + */ + void setGeneratedSql(String sql); } diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java index 15551602b..1f634a33f 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java +++ b/src/main/java/com/avaje/ebeaninternal/api/SpiUpdatePlan.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.sql.SQLException; - import com.avaje.ebean.bean.EntityBean; import com.avaje.ebeaninternal.server.persist.dml.DmlHandler; import com.avaje.ebeaninternal.server.persist.dmlbind.Bindable; +import java.sql.SQLException; + /** * A plan for executing bean updates for a given set of changed properties. *

@@ -26,41 +26,41 @@ public interface SpiUpdatePlan { *

*/ 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. - */ - void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - /** - * Return the time this plan was created. - */ - long getTimeCreated(); + /** + * 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. + */ + void bindSet(DmlHandler bind, EntityBean bean) throws SQLException; - /** - * Return the time this plan was last used. - */ - Long getTimeLastUsed(); + /** + * Return the time this plan was created. + */ + long getTimeCreated(); - /** - * Return the hash key for this plan. - */ - Integer getKey(); + /** + * Return the time this plan was last used. + */ + Long getTimeLastUsed(); - /** - * Return the concurrency mode for this plan. - */ - ConcurrencyMode getMode(); + /** + * Return the hash key for this plan. + */ + Integer getKey(); - /** - * Return the update SQL statement. - */ - String getSql(); + /** + * Return the concurrency mode for this plan. + */ + ConcurrencyMode getMode(); - /** - * Return the set of bindable update properties. - */ - Bindable getSet(); + /** + * Return the update SQL statement. + */ + String getSql(); -} \ No newline at end of file + /** + * Return the set of bindable update properties. + */ + Bindable getSet(); + +} diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java index 6f81f9aa1..2f1d0a2f9 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEvent.java @@ -1,10 +1,10 @@ package com.avaje.ebeaninternal.api; import com.avaje.ebeaninternal.server.cache.CacheChangeSet; -import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import com.avaje.ebeaninternal.server.core.PersistRequestBean; import com.avaje.ebeaninternal.server.deploy.BeanDescriptor; import com.avaje.ebeaninternal.server.transaction.DeleteByIdMap; +import com.avaje.ebeanservice.docstore.api.DocStoreUpdates; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java index 3b770ce92..608091511 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventBeans.java @@ -1,11 +1,11 @@ package com.avaje.ebeaninternal.api; -import java.util.ArrayList; -import java.util.List; - import com.avaje.ebeaninternal.server.cache.CacheChangeSet; import com.avaje.ebeaninternal.server.core.PersistRequestBean; +import java.util.ArrayList; +import java.util.List; + /** * Lists of inserted updated and deleted beans that have a BeanPersistListener. *

@@ -17,28 +17,28 @@ public class TransactionEventBeans { final 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); - } - - /** - * Collect the cache changes. + /** + * Return the list of PersistRequests that BeanListeners are interested in. */ - public void notifyCache(CacheChangeSet changeSet) { + public List> getRequests() { + return requests; + } + + /** + * Add a bean for BeanListener notification. + */ + public void add(PersistRequestBean request) { + + requests.add(request); + } + + /** + * Collect the cache changes. + */ + public void notifyCache(CacheChangeSet changeSet) { for (PersistRequestBean request : requests) { request.notifyCache(changeSet); } - } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java index 1922b6bee..c96580f4a 100644 --- a/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java +++ b/src/main/java/com/avaje/ebeaninternal/api/TransactionEventTable.java @@ -1,5 +1,9 @@ package com.avaje.ebeaninternal.api; +import com.avaje.ebean.event.BulkTableEvent; +import com.avaje.ebeaninternal.server.cluster.BinaryMessage; +import com.avaje.ebeaninternal.server.cluster.BinaryMessageList; + import java.io.DataInput; import java.io.DataOutputStream; import java.io.IOException; @@ -8,136 +12,133 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; -import com.avaje.ebean.event.BulkTableEvent; -import com.avaje.ebeaninternal.server.cluster.BinaryMessage; -import com.avaje.ebeaninternal.server.cluster.BinaryMessageList; - public final class TransactionEventTable implements Serializable { - private static final long serialVersionUID = 2236555729767483264L; - - private final Map map = new HashMap<>(); - - public String toString() { - return "TransactionEventTable " + map.values(); + private static final long serialVersionUID = 2236555729767483264L; + + private final Map map = new HashMap<>(); + + public String toString() { + return "TransactionEventTable " + map.values(); + } + + public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { + + for (TableIUD tableIud : map.values()) { + tableIud.writeBinaryMessage(msgList); + } + } + + public void readBinaryMessage(DataInput dataInput) throws IOException { + + TableIUD tableIud = TableIUD.readBinaryMessage(dataInput); + map.put(tableIud.getTableName(), tableIud); + } + + + public void add(TransactionEventTable table) { + + for (TableIUD iud : table.values()) { + add(iud); + } + } + + public void add(String table, boolean insert, boolean update, boolean delete) { + + table = table.toUpperCase(); + + add(new TableIUD(table, insert, update, delete)); + } + + public void add(TableIUD newTableIUD) { + + TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD); + if (existingTableIUD != null) { + newTableIUD.add(existingTableIUD); + } + } + + public boolean isEmpty() { + return map.isEmpty(); + } + + public Collection values() { + return map.values(); + } + + public static class TableIUD implements Serializable, BulkTableEvent { + + private static final long serialVersionUID = -1958317571064162089L; + + private final String table; + private boolean insert; + private boolean update; + private boolean delete; + + public TableIUD(String table, boolean insert, boolean update, boolean delete) { + this.table = table; + this.insert = insert; + this.update = update; + this.delete = delete; + } + + public static TableIUD readBinaryMessage(DataInput dataInput) throws IOException { + + String table = dataInput.readUTF(); + boolean insert = dataInput.readBoolean(); + boolean update = dataInput.readBoolean(); + boolean delete = dataInput.readBoolean(); + + return new TableIUD(table, insert, update, delete); } public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { - for (TableIUD tableIud : map.values()) { - tableIud.writeBinaryMessage(msgList); - } - } - - public void readBinaryMessage(DataInput dataInput) throws IOException { - - TableIUD tableIud = TableIUD.readBinaryMessage(dataInput); - map.put(tableIud.getTableName(), tableIud); + BinaryMessage msg = new BinaryMessage(table.length() + 10); + DataOutputStream os = msg.getOs(); + os.writeInt(BinaryMessage.TYPE_TABLEIUD); + os.writeUTF(table); + os.writeBoolean(insert); + os.writeBoolean(update); + os.writeBoolean(delete); + + msgList.add(msg); } - - public void add(TransactionEventTable table){ - - for (TableIUD iud : table.values()) { - add(iud); - } - } + public String toString() { + return "TableIUD " + table + " i:" + insert + " u:" + update + " d:" + delete; + } - public void add(String table, boolean insert, boolean update, boolean delete){ + private void add(TableIUD other) { + if (other.insert) { + insert = true; + } + if (other.update) { + update = true; + } + if (other.delete) { + delete = true; + } + } - table = table.toUpperCase(); - - add(new TableIUD(table, insert, update, delete)); - } - - public void add(TableIUD newTableIUD){ + public String getTableName() { + return table; + } - TableIUD existingTableIUD = map.put(newTableIUD.getTableName(), newTableIUD); - if (existingTableIUD != null){ - newTableIUD.add(existingTableIUD); - } - } - - public boolean isEmpty() { - return map.isEmpty(); - } - - public Collection values() { - return map.values(); - } - - public static class TableIUD implements Serializable, BulkTableEvent { - - private static final long serialVersionUID = -1958317571064162089L; - - private final String table; - private boolean insert; - private boolean update; - private boolean delete; - - public TableIUD(String table, boolean insert, boolean update, boolean delete){ - this.table = table; - this.insert = insert; - this.update = update; - this.delete = delete; - } - - public static TableIUD readBinaryMessage(DataInput dataInput) throws IOException { - - String table = dataInput.readUTF(); - boolean insert = dataInput.readBoolean(); - boolean update = dataInput.readBoolean(); - boolean delete = dataInput.readBoolean(); - - return new TableIUD(table, insert, update, delete); - } - - public void writeBinaryMessage(BinaryMessageList msgList) throws IOException { - - BinaryMessage msg = new BinaryMessage(table.length()+10); - DataOutputStream os = msg.getOs(); - os.writeInt(BinaryMessage.TYPE_TABLEIUD); - os.writeUTF(table); - os.writeBoolean(insert); - os.writeBoolean(update); - os.writeBoolean(delete); - - msgList.add(msg); - } - - public String toString() { - return "TableIUD "+table+" i:"+insert+" u:"+update+" d:"+delete; - } - - private void add(TableIUD other) { - if (other.insert){ - insert = true; - } - if (other.update){ - update = true; - } - if (other.delete){ - delete = true; - } - } - public String getTableName() { - return table; - } + public boolean isInsert() { + return insert; + } - public boolean isInsert() { - return insert; - } + public boolean isUpdate() { + return update; + } - public boolean isUpdate() { - return update; - } + public boolean isDelete() { + return delete; + } - public boolean isDelete() { - return delete; - } - - public boolean isUpdateOrDelete() { - return update || delete; - } - } + public boolean isUpdateOrDelete() { + return update || delete; + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java index a0020f584..fd104ac5a 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/DdlScript.java @@ -1,4 +1,3 @@ - package com.avaje.ebeaninternal.extraddl.model; import javax.xml.bind.annotation.XmlAccessType; @@ -11,9 +10,9 @@ import javax.xml.bind.annotation.XmlValue; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <simpleContent>
@@ -24,93 +23,79 @@ import javax.xml.bind.annotation.XmlValue;
  *   </simpleContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "value" + "value" }) @XmlRootElement(name = "ddl-script") public class DdlScript { - @XmlValue - protected String value; - @XmlAttribute(name = "name", required = true) - protected String name; - @XmlAttribute(name = "platforms") - protected String platforms; + @XmlValue + protected String value; + @XmlAttribute(name = "name", required = true) + protected String name; + @XmlAttribute(name = "platforms") + protected String platforms; - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() { + return value; + } - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) { + this.value = value; + } - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() { + return name; + } - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) { + this.name = value; + } - /** - * Gets the value of the platforms property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPlatforms() { - return platforms; - } + /** + * Gets the value of the platforms property. + * + * @return possible object is + * {@link String } + */ + public String getPlatforms() { + return platforms; + } - /** - * Sets the value of the platforms property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPlatforms(String value) { - this.platforms = value; - } + /** + * Sets the value of the platforms property. + * + * @param value allowed object is + * {@link String } + */ + public void setPlatforms(String value) { + this.platforms = value; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java index 79d532c70..3c7867262 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdl.java @@ -1,20 +1,19 @@ - package com.avaje.ebeaninternal.extraddl.model; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; /** *

Java class for anonymous complex type. - * + *

*

The following schema fragment specifies the expected content contained within this class. - * + *

*

  * <complexType>
  *   <complexContent>
@@ -26,46 +25,42 @@ import javax.xml.bind.annotation.XmlType;
  *   </complexContent>
  * </complexType>
  * 
- * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { - "ddlScript" + "ddlScript" }) @XmlRootElement(name = "extra-ddl") public class ExtraDdl { - @XmlElement(name = "ddl-script", required = true) - protected List ddlScript; + @XmlElement(name = "ddl-script", required = true) + protected List ddlScript; - /** - * Gets the value of the ddlScript property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the ddlScript property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getDdlScript().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link DdlScript } - * - * - */ - public List getDdlScript() { - if (ddlScript == null) { - ddlScript = new ArrayList<>(); - } - return this.ddlScript; + /** + * Gets the value of the ddlScript property. + *

+ *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the ddlScript property. + *

+ *

+ * For example, to add a new item, do as follows: + *

+   *    getDdlScript().add(newItem);
+   * 
+ *

+ *

+ *

+ * Objects of the following type(s) are allowed in the list + * {@link DdlScript } + */ + public List getDdlScript() { + if (ddlScript == null) { + ddlScript = new ArrayList<>(); } + return this.ddlScript; + } } diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java index 2a3767785..1a5e1fbf0 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ExtraDdlXmlReader.java @@ -36,8 +36,9 @@ public class ExtraDdlXmlReader { /** * Return true if the script platforms is a match/supported for the given platform. + * * @param platformName The database platform we are generating/running DDL for - * @param platforms The platforms (comma delimited) this script should run for + * @param platforms The platforms (comma delimited) this script should run for */ public static boolean matchPlatform(String platformName, String platforms) { if (platforms == null || platforms.trim().isEmpty()) { diff --git a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java index 07009ef1a..c73abca6f 100644 --- a/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java +++ b/src/main/java/com/avaje/ebeaninternal/extraddl/model/ObjectFactory.java @@ -1,48 +1,43 @@ - package com.avaje.ebeaninternal.extraddl.model; import javax.xml.bind.annotation.XmlRegistry; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.avaje.ebeaninternal.extraddl.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.avaje.ebeaninternal.extraddl.model package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are * provided in this class. - * */ @XmlRegistry public class ObjectFactory { - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.extraddl.model - * - */ - public ObjectFactory() { - } + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.avaje.ebeaninternal.extraddl.model + */ + public ObjectFactory() { + } - /** - * Create an instance of {@link DdlScript } - * - */ - public DdlScript createDdlScript() { - return new DdlScript(); - } + /** + * Create an instance of {@link DdlScript } + */ + public DdlScript createDdlScript() { + return new DdlScript(); + } - /** - * Create an instance of {@link ExtraDdl } - * - */ - public ExtraDdl createExtraDdl() { - return new ExtraDdl(); - } + /** + * Create an instance of {@link ExtraDdl } + */ + public ExtraDdl createExtraDdl() { + return new ExtraDdl(); + } }