diff --git a/ebean-api/src/main/java/io/ebean/config/SlowQueryEvent.java b/ebean-api/src/main/java/io/ebean/config/SlowQueryEvent.java index 6afd715025..fc6413059f 100644 --- a/ebean-api/src/main/java/io/ebean/config/SlowQueryEvent.java +++ b/ebean-api/src/main/java/io/ebean/config/SlowQueryEvent.java @@ -1,50 +1,29 @@ package io.ebean.config; +import io.ebean.ProfileLocation; import io.ebean.bean.ObjectGraphNode; +import java.util.List; + /** - * Slow query event. + * The data for the slow query. */ -public class SlowQueryEvent { - - private final String sql; - - private final long timeMillis; - - private final int rowCount; - - private final ObjectGraphNode originNode; - - /** - * Construct with the SQL and execution time in millis. - */ - public SlowQueryEvent(String sql, long timeMillis, int rowCount, ObjectGraphNode originNode) { - this.sql = sql; - this.timeMillis = timeMillis; - this.rowCount = rowCount; - this.originNode = originNode; - } +public interface SlowQueryEvent { /** * Return the SQL for the slow query. */ - public String getSql() { - return sql; - } + String getSql(); /** * Return the execution time in millis. */ - public long getTimeMillis() { - return timeMillis; - } + long getTimeMillis(); /** * Return the total row count associated with the query. */ - public int getRowCount() { - return rowCount; - } + int getRowCount(); /** * Return the origin point for the root query. @@ -53,7 +32,20 @@ public int getRowCount() { * shows the code that invoked the query. *

*/ - public ObjectGraphNode getOriginNode() { - return originNode; - } + ObjectGraphNode getOriginNode(); + + /** + * Return the bind parameters. + */ + List getBindParams(); + + /** + * Return the label. + */ + String getLabel(); + + /** + * Return the profile location. + */ + ProfileLocation getProfileLocation(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java index 030042d96b..f5153464f6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java @@ -84,7 +84,7 @@ public interface SpiExpression extends Expression { * * @param request the associated request. */ - void addBindValues(SpiExpressionRequest request); + void addBindValues(SpiExpressionBind request); /** * Validate all the properties/paths associated with this expression. diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionBind.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionBind.java new file mode 100644 index 0000000000..2630e067dc --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionBind.java @@ -0,0 +1,29 @@ +package io.ebeaninternal.api; + +import io.ebeaninternal.server.deploy.BeanDescriptor; + +/** + * Expression bind values capture. + */ +public interface SpiExpressionBind { + + /** + * Return the bean descriptor for the root type. + */ + BeanDescriptor descriptor(); + + /** + * Add an encryption key to bind to this request. + */ + void addBindEncryptKey(Object encryptKey); + + /** + * Add a bind value to this request. + */ + void addBindValue(Object bindValue); + + /** + * Escapes a string to use it as exact match in Like clause. + */ + String escapeLikeString(String value); +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionRequest.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionRequest.java index b963175479..bfbd18d102 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionRequest.java @@ -1,7 +1,6 @@ package io.ebeaninternal.api; import io.ebeaninternal.server.core.SpiOrmQueryRequest; -import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.expression.platform.DbExpressionHandler; import io.ebeaninternal.server.expression.platform.DbExpressionRequest; @@ -10,7 +9,7 @@ /** * Request object used for gathering expression sql and bind values. */ -public interface SpiExpressionRequest extends DbExpressionRequest { +public interface SpiExpressionRequest extends SpiExpressionBind, DbExpressionRequest { /** * Return the DB specific handler for JSON and ARRAY expressions. @@ -22,11 +21,6 @@ public interface SpiExpressionRequest extends DbExpressionRequest { */ String parseDeploy(String logicalProp); - /** - * Return the bean descriptor for the root type. - */ - BeanDescriptor descriptor(); - /** * Return the associated QueryRequest. */ @@ -58,16 +52,6 @@ public interface SpiExpressionRequest extends DbExpressionRequest { */ SpiExpressionRequest parse(String expression); - /** - * Add an encryption key to bind to this request. - */ - void addBindEncryptKey(Object encryptKey); - - /** - * Add a bind value to this request. - */ - void addBindValue(Object bindValue); - /** * Return the accumulated expression sql for all expressions in this request. */ @@ -88,11 +72,6 @@ public interface SpiExpressionRequest extends DbExpressionRequest { */ void appendLike(boolean rawLikeExpression); - /** - * Escapes a string to use it as exact match in Like clause. - */ - String escapeLikeString(String value); - /** * Append IN expression taking into account platform and type support for Multi-value. */ diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DSlowQueryEvent.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DSlowQueryEvent.java new file mode 100644 index 0000000000..5a18238dde --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DSlowQueryEvent.java @@ -0,0 +1,70 @@ +package io.ebeaninternal.server.core; + +import io.ebean.ProfileLocation; +import io.ebean.bean.ObjectGraphNode; +import io.ebean.config.SlowQueryEvent; + +import java.util.List; + +/** + * Slow query event. + */ +final class DSlowQueryEvent implements SlowQueryEvent { + + private final String sql; + private final long timeMillis; + private final int rowCount; + private final ObjectGraphNode originNode; + private final List bindParams; + private final String label; + private final ProfileLocation profileLocation; + + /** + * Construct with the SQL and execution time in millis. + */ + DSlowQueryEvent(String sql, long timeMillis, int rowCount, ObjectGraphNode originNode, + List bindParams, String label, ProfileLocation profileLocation) { + this.sql = sql; + this.timeMillis = timeMillis; + this.rowCount = rowCount; + this.originNode = originNode; + this.bindParams = bindParams; + this.profileLocation = profileLocation; + this.label = label != null ? label : profileLocation == null ? null : profileLocation.label(); + } + + @Override + public String getSql() { + return sql; + } + + @Override + public long getTimeMillis() { + return timeMillis; + } + + @Override + public int getRowCount() { + return rowCount; + } + + @Override + public ObjectGraphNode getOriginNode() { + return originNode; + } + + @Override + public List getBindParams() { + return bindParams; + } + + @Override + public String getLabel() { + return label; + } + + @Override + public ProfileLocation getProfileLocation() { + return profileLocation; + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java index 89229f3004..0c5a8b45f3 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java @@ -2184,7 +2184,9 @@ public SpiJsonContext jsonExtended() { @Override public void slowQueryCheck(long timeMicros, int rowCount, SpiQuery query) { if (timeMicros > slowQueryMicros && slowQueryListener != null) { - slowQueryListener.process(new SlowQueryEvent(query.getGeneratedSql(), timeMicros / 1000L, rowCount, query.parentNode())); + List bindParams = new SlowQueryBindCapture(query).capture(); + slowQueryListener.process(new DSlowQueryEvent(query.getGeneratedSql(), timeMicros / 1000L, rowCount, + query.parentNode(), bindParams, query.label(), query.profileLocation())); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultSlowQueryListener.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultSlowQueryListener.java index eaa79cd9f0..43717788fe 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultSlowQueryListener.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultSlowQueryListener.java @@ -1,10 +1,12 @@ package io.ebeaninternal.server.core; import io.avaje.applog.AppLog; -import io.ebean.bean.ObjectGraphNode; +import io.ebean.ProfileLocation; import io.ebean.config.SlowQueryEvent; import io.ebean.config.SlowQueryListener; +import java.util.List; + import static java.lang.System.Logger.Level.WARNING; /** @@ -16,11 +18,10 @@ final class DefaultSlowQueryListener implements SlowQueryListener { @Override public void process(SlowQueryEvent event) { - String firstStack = ""; - ObjectGraphNode node = event.getOriginNode(); - if (node != null) { - firstStack = node.origin().top(); - } - log.log(WARNING, "Slow query warning - millis:{0} rows:{1} caller[{2}] sql[{3}]", event.getTimeMillis(), event.getRowCount(), firstStack, event.getSql()); + ProfileLocation profileLocation = event.getProfileLocation(); + String loc = profileLocation == null ? "" : profileLocation.fullLocation(); + List bindParams = event.getBindParams(); + log.log(WARNING, "Slow query warning - millis:{0} rows:{1} location:{2} sql[{3}] params{4}", + event.getTimeMillis(), event.getRowCount(), loc, event.getSql(), bindParams); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/SlowQueryBindCapture.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/SlowQueryBindCapture.java new file mode 100644 index 0000000000..0fdd425c24 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/SlowQueryBindCapture.java @@ -0,0 +1,71 @@ +package io.ebeaninternal.server.core; + +import io.ebeaninternal.api.BindParams; +import io.ebeaninternal.api.SpiExpressionBind; +import io.ebeaninternal.api.SpiExpressionList; +import io.ebeaninternal.api.SpiQuery; +import io.ebeaninternal.server.deploy.BeanDescriptor; +import io.ebeaninternal.server.persist.MultiValueWrapper; + +import java.util.ArrayList; +import java.util.List; + +final class SlowQueryBindCapture implements SpiExpressionBind { + + private final SpiQuery query; + private final List bindParams = new ArrayList<>(); + + SlowQueryBindCapture(SpiQuery query) { + this.query = query; + } + + List capture() { + var params = query.bindParams(); + if (params != null) { + var positionedParameters = params.positionedParameters(); + for (BindParams.Param param : positionedParameters) { + if (param.isInParam()) { + add(param.inValue()); + } + } + } + Object id = query.getId(); + if (id != null) { + add(id); + } + SpiExpressionList spiExpressionList = query.whereExpressions(); + if (spiExpressionList != null) { + spiExpressionList.addBindValues(this); + } + return bindParams; + } + + private void add(Object value) { + if (value instanceof MultiValueWrapper) { + var mvw = (MultiValueWrapper) value; + bindParams.add(mvw.getValues()); + } else { + bindParams.add(value); + } + } + + @Override + public BeanDescriptor descriptor() { + return query.descriptor(); + } + + @Override + public void addBindValue(Object bindValue) { + add(bindValue); + } + + @Override + public void addBindEncryptKey(Object encryptKey) { + bindParams.add("*"); + } + + @Override + public String escapeLikeString(String value) { + return query.descriptor().ebeanServer().databasePlatform().escapeLikeString(value); + } +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinder.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinder.java index 01aa079df6..07b531f3a5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinder.java @@ -1,6 +1,7 @@ package io.ebeaninternal.server.deploy.id; import io.ebean.bean.EntityBean; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.core.DefaultSqlUpdate; import io.ebeaninternal.server.deploy.BeanProperty; @@ -143,7 +144,7 @@ default int size() { /** * Binds multiple id value to a request. */ - void addBindValues(SpiExpressionRequest request, Collection ids); + void addBindValues(SpiExpressionBind request, Collection ids); /** * Return the sql for binding the id using an IN clause. diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java index ae3353aa91..104f00964d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmbedded.java @@ -2,6 +2,7 @@ import io.ebean.bean.EntityBean; import io.ebean.util.SplitName; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.core.DefaultSqlUpdate; import io.ebeaninternal.server.deploy.BeanDescriptor; @@ -269,7 +270,7 @@ public void addBindValues(DefaultSqlUpdate sqlUpdate, Collection values) { } @Override - public void addBindValues(SpiExpressionRequest request, Collection values) { + public void addBindValues(SpiExpressionBind request, Collection values) { for (Object value : values) { final EntityBean bean = (EntityBean) value; for (BeanProperty prop : props) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmpty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmpty.java index d79ab892fb..82b0ca7638 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmpty.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderEmpty.java @@ -1,6 +1,7 @@ package io.ebeaninternal.server.deploy.id; import io.ebean.bean.EntityBean; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.bind.DataBind; import io.ebeaninternal.server.core.DefaultSqlUpdate; @@ -130,7 +131,7 @@ public void addBindValues(DefaultSqlUpdate sqlUpdate, Collection ids) { } @Override - public void addBindValues(SpiExpressionRequest request, Collection ids) { + public void addBindValues(SpiExpressionBind request, Collection ids) { } @Override diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderSimple.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderSimple.java index c19b8ad317..6807590bcc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderSimple.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/id/IdBinderSimple.java @@ -2,6 +2,7 @@ import io.ebean.bean.EntityBean; import io.ebean.core.type.ScalarType; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.core.DefaultSqlUpdate; import io.ebeaninternal.server.core.InternString; @@ -143,7 +144,7 @@ public void addBindValues(DefaultSqlUpdate sqlUpdate, Collection ids) { } @Override - public void addBindValues(SpiExpressionRequest request, Collection values) { + public void addBindValues(SpiExpressionBind request, Collection values) { List copy = new ArrayList<>(values); copy.replaceAll(idValue -> convertSetId(idValue, null)); request.addBindValue(new MultiValueWrapper(copy)); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java index 08deef5ea2..e47a825910 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java @@ -97,7 +97,7 @@ public void validate(SpiExpressionValidation validation) { validation.validate(propName); } - protected final ElPropertyValue getElProp(SpiExpressionRequest request) { + protected final ElPropertyValue getElProp(SpiExpressionBind request) { return request.descriptor().elGetValue(propName); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractTextExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractTextExpression.java index cc07e2a8db..6c5a878eca 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractTextExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractTextExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; /** @@ -28,7 +29,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { // do nothing, only execute against document store } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java index 4742f4c87c..ee58bb7222 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AllEqualsExpression.java @@ -51,7 +51,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { if (propMap.isEmpty()) { return; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java index a50b484694..ce37fc2658 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayContainsExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import java.io.IOException; @@ -72,7 +73,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (Object value : values) { request.addBindValue(value); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java index 5c031f78ec..e695c31afd 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ArrayIsEmptyExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import java.io.IOException; @@ -49,7 +50,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { // nothing to bind } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java index c2fd447790..f17928b916 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; @@ -34,7 +35,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { ElPropertyValue prop = getElProp(request); if (prop != null && prop.isDbEncrypted()) { // bind the key as well as the value diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java index 9ce453eb67..e0a2413005 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java @@ -75,7 +75,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { request.addBindValue(val()); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java index 0f93dc73f8..c405235b5b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BitwiseExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; /** @@ -52,7 +53,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { request.addBindValue(flags); request.addBindValue(match); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java index ac98f1824b..17ca57f49b 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/CaseInsensitiveEqualExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; @@ -33,7 +34,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { ElPropertyValue prop = getElProp(request); if (prop != null && prop.isDbEncrypted()) { // bind the key as well as the value diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java index 7483a33358..c33e163dbc 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java @@ -5,12 +5,7 @@ import io.ebean.bean.EntityBean; import io.ebean.event.BeanQueryRequest; import io.ebean.util.SplitName; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; -import io.ebeaninternal.api.SpiExpressionValidation; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.deploy.BeanProperty; import io.ebeaninternal.server.deploy.BeanPropertyAssocOne; @@ -194,8 +189,7 @@ public void validate(SpiExpressionValidation validation) { * Adds bind values to the request. */ @Override - public void addBindValues(SpiExpressionRequest request) { - + public void addBindValues(SpiExpressionBind request) { for (SpiExpression item : list) { item.addBindValues(request); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java index e049d5d87c..59772588f2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java @@ -591,7 +591,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (SpiExpression expr : list) { expr.addBindValues(request); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java index 81f00e49d5..b45e6ed5b0 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java @@ -99,7 +99,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (Object bindParam : bindParams) { request.addBindValue(bindParam); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java index 497c417c69..4ce5a6f8f7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsSqlQueryExpression.java @@ -77,7 +77,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (Object bindParam : bindParams) { request.addBindValue(bindParam); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java index f66ecd0ab1..f621b2aea2 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java @@ -45,7 +45,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { // 'flatten' EmbeddedId and multiple ID cases // into an array of the underlying scalar field values for (Object bindIdValue : request.descriptor().bindIdValues(value)) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java index 41805a82b5..a2203dad13 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdInExpression.java @@ -61,7 +61,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { if (idCollection.isEmpty()) { return; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java index e47fcf9258..a1c6fc8774 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InExpression.java @@ -2,10 +2,7 @@ import io.ebean.bean.EntityBean; import io.ebean.event.BeanQueryRequest; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.el.ElPropertyValue; import io.ebeaninternal.server.persist.MultiValueWrapper; @@ -103,7 +100,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { if (empty) { return; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java index e0c975ffe2..366333678c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InPairsExpression.java @@ -3,10 +3,7 @@ import io.ebean.Pairs; import io.ebean.Pairs.Entry; import io.ebean.event.BeanQueryRequest; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.persist.MultiValueWrapper; import java.util.ArrayList; @@ -58,8 +55,7 @@ public void writeDocQuery(DocQueryContext context) { } @Override - public void addBindValues(SpiExpressionRequest request) { - + public void addBindValues(SpiExpressionBind request) { // Note at this point entries may have been removed when used with l2 caching // ... for each l2 cache hit an entry was removed this.concatBindValues = new ArrayList<>(entries.size()); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java index 47b5e6f4aa..b908fce721 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InRangeExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; @@ -32,7 +33,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { ElPropertyValue prop = getElProp(request); if (prop != null && prop.isDbEncrypted()) { // bind the key twice, for both values diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java index 8fa2fb8cbc..f1765f3f9c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/InTuplesExpression.java @@ -2,10 +2,7 @@ import io.ebean.InTuples; import io.ebean.service.SpiInTuples; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; +import io.ebeaninternal.api.*; import java.util.List; @@ -37,7 +34,7 @@ public void writeDocQuery(DocQueryContext context) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (Object[] entry : entries) { for (Object value : entry) { requireNonNull(value); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java index 299961da92..8dd3062041 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IsEmptyExpression.java @@ -1,10 +1,7 @@ package io.ebeaninternal.server.expression; import io.ebean.util.SplitName; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.el.ElPropertyValue; @@ -53,7 +50,7 @@ public String getPropName() { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { // no bind values } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java index 07876e629a..a6e32958d8 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JsonPathExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import java.io.IOException; @@ -102,7 +103,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { if (value != null) { // value is null for EXISTS/NOT EXISTS request.addBindValue(value); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java index d5c718531f..020451e8bd 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java @@ -141,7 +141,7 @@ public Junction addAll(ExpressionList addList) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (SpiExpression expr : exprList.internalList()) { expr.addBindValues(request); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java index c99c648aa7..addf8c738d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LikeExpression.java @@ -3,6 +3,7 @@ import io.ebean.LikeType; import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; @@ -25,7 +26,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { ElPropertyValue prop = getElProp(request); if (prop != null && prop.isDbEncrypted()) { // bind the key as well as the value @@ -78,7 +79,7 @@ public boolean isSameByBind(SpiExpression other) { return strValue().equals(that.strValue()); } - private static String getValue(String value, boolean caseInsensitive, LikeType type, SpiExpressionRequest request) { + private static String getValue(String value, boolean caseInsensitive, LikeType type, SpiExpressionBind request) { if (caseInsensitive) { value = value.toLowerCase(); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java index a98ac8166c..47cc0805cf 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java @@ -3,12 +3,7 @@ import io.ebean.Expression; import io.ebean.Junction; import io.ebean.event.BeanQueryRequest; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; -import io.ebeaninternal.api.SpiExpressionValidation; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import java.io.IOException; @@ -133,7 +128,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { expOne.addBindValues(request); expTwo.addBindValues(request); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java index ce960c3f4d..05dd4c5b41 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NativeILikeExpression.java @@ -3,6 +3,7 @@ import io.ebean.LikeType; import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import io.ebeaninternal.server.el.ElPropertyValue; @@ -23,8 +24,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { - + public void addBindValues(SpiExpressionBind request) { ElPropertyValue prop = getElProp(request); if (prop != null && prop.isDbEncrypted()) { // bind the key as well as the value diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java index 72a495fd93..ebd76e615c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java @@ -1,13 +1,8 @@ package io.ebeaninternal.server.expression; import io.ebean.event.BeanQueryRequest; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; -import io.ebeaninternal.api.SpiExpressionValidation; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; -import io.ebeaninternal.api.NaturalKeyQueryData; import java.io.IOException; @@ -94,7 +89,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { delegate.addBindValues(request); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java index da009c90e8..c963bdfb76 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java @@ -78,7 +78,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { // nothing to do } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java index 6eae8b1fa1..09611c0d25 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java @@ -2,12 +2,7 @@ import io.ebean.Expression; import io.ebean.event.BeanQueryRequest; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; -import io.ebeaninternal.api.SpiExpressionValidation; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import java.io.IOException; @@ -73,7 +68,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { exp.addBindValues(request); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java index 7168f61c81..ecac6b3ad4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NullExpression.java @@ -1,10 +1,7 @@ package io.ebeaninternal.server.expression; import io.ebean.util.SplitName; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.ManyWhereJoins; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.deploy.BeanDescriptor; import io.ebeaninternal.server.el.ElPropertyValue; @@ -51,7 +48,7 @@ public void writeDocQuery(DocQueryContext context) throws IOException { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java index db64b2ea7f..dc6944ea15 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/RawExpression.java @@ -42,7 +42,7 @@ public void validate(SpiExpressionValidation validation) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { if (values != null) { for (Object value : values) { if (value instanceof Collection) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java index 59bc76d039..95098a6820 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SimpleExpression.java @@ -2,10 +2,7 @@ import io.ebean.bean.EntityBean; import io.ebean.plugin.ExpressionPath; -import io.ebeaninternal.api.BindValuesKey; -import io.ebeaninternal.api.NaturalKeyQueryData; -import io.ebeaninternal.api.SpiExpression; -import io.ebeaninternal.api.SpiExpressionRequest; +import io.ebeaninternal.api.*; import io.ebeaninternal.server.el.ElPropertyValue; import java.io.IOException; @@ -68,8 +65,7 @@ public Object getValue() { } @Override - public void addBindValues(SpiExpressionRequest request) { - + public void addBindValues(SpiExpressionBind request) { ElPropertyValue prop = getElProp(request); if (prop != null) { if (prop.isAssocId()) { diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java index 44adcbeb51..70813b25df 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryExpression.java @@ -79,7 +79,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (Object bindParam : bindParams) { request.addBindValue(bindParam); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java index d69cdc1bf8..35898bd3af 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/SubQueryRawExpression.java @@ -2,6 +2,7 @@ import io.ebeaninternal.api.BindValuesKey; import io.ebeaninternal.api.SpiExpression; +import io.ebeaninternal.api.SpiExpressionBind; import io.ebeaninternal.api.SpiExpressionRequest; import java.util.Arrays; @@ -47,7 +48,7 @@ public void addSql(SpiExpressionRequest request) { } @Override - public void addBindValues(SpiExpressionRequest request) { + public void addBindValues(SpiExpressionBind request) { for (Object bindParam : bindParams) { request.addBindValue(bindParam); } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/SlowQueryBindCaptureTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/SlowQueryBindCaptureTest.java new file mode 100644 index 0000000000..a3d7c05edf --- /dev/null +++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/SlowQueryBindCaptureTest.java @@ -0,0 +1,74 @@ +package io.ebeaninternal.server.core; + +import io.ebean.DB; +import io.ebean.Database; +import io.ebean.Query; +import io.ebeaninternal.api.SpiQuery; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.tests.model.basic.Customer; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class SlowQueryBindCaptureTest { + + static Database db; + + @BeforeAll + static void beforeAll() { + db = DB.getDefault(); + db.script().run("/h2-init.sql"); + } + + @Test + void bindParams_capture() { + String sql = "select * from o_customer p where p.status = ?"; + Query query = db.findNative(Customer.class, sql) + .setParameter("N"); + query.findList(); + + var sbc = new SlowQueryBindCapture((SpiQuery) query); + List bindParams = sbc.capture(); + assertThat(bindParams).hasSize(1); + assertThat(bindParams.get(0)).isEqualTo("N"); + } + + @Test + void expressionsCapture() { + Query query = db.find(Customer.class) + .where() + .startsWith("name", "rob") + .eq("status", "N") + .query(); + + query.findList(); + + var sbc = new SlowQueryBindCapture((SpiQuery) query); + List bindParams = sbc.capture(); + assertThat(bindParams).hasSize(2); + assertThat(bindParams.get(0)).isEqualTo("rob%"); + assertThat(bindParams.get(1)).isEqualTo("N"); + } + + @SuppressWarnings("unchecked") + @Test + void multiValueCapture() { + Query query = db.find(Customer.class) + .where() + .in("id", List.of(1, 2, 3, 4)) + .query(); + + query.findList(); + + var sbc = new SlowQueryBindCapture((SpiQuery) query); + List bindParams = sbc.capture(); + assertThat(bindParams).hasSize(1); + Object bindParam0 = bindParams.get(0); + assertThat(bindParam0).isInstanceOf(ArrayList.class); + var values = (ArrayList) bindParam0; + assertThat(values).contains(1, 2, 3, 4); + } +} diff --git a/ebean-core/src/test/resources/h2-init.sql b/ebean-core/src/test/resources/h2-init.sql index 10f672d4b1..7e6d478cd5 100644 --- a/ebean-core/src/test/resources/h2-init.sql +++ b/ebean-core/src/test/resources/h2-init.sql @@ -1,5 +1,5 @@ -create table animal ( +create table if not exists animal ( species varchar(255) not null, id bigint generated by default as identity not null, shelter_id bigint, @@ -11,14 +11,14 @@ create table animal ( constraint pk_animal primary key (id) ); -create table animal_shelter ( +create table if not exists animal_shelter ( id bigint generated by default as identity not null, name varchar(255), version bigint not null, constraint pk_animal_shelter primary key (id) ); -create table o_customer ( +create table if not exists o_customer ( id integer generated by default as identity not null, status varchar(1), name varchar(40) not null, diff --git a/ebean-querybean/src/test/resources/application-test.properties b/ebean-querybean/src/test/resources/application-test.properties index 5b5481d454..40926ea64d 100644 --- a/ebean-querybean/src/test/resources/application-test.properties +++ b/ebean-querybean/src/test/resources/application-test.properties @@ -4,6 +4,7 @@ ebean.ddl.initSql=init-db.sql ebean.dumpMetricsOnShutdown=true ebean.dumpMetricsOptions=sql,hash,loc ebean.includeLabelInSql=true +ebean.slowQueryMillis=1 datasource.default=h2 diff --git a/ebean-test/src/test/resources/ebean.properties b/ebean-test/src/test/resources/ebean.properties index 739bc554c9..6e3485c75b 100644 --- a/ebean-test/src/test/resources/ebean.properties +++ b/ebean-test/src/test/resources/ebean.properties @@ -19,6 +19,7 @@ ebean.encryptKeyManager=org.tests.basic.encrypt.BasicEncyptKeyManager #ebean.autoTune.profilingUpdateFrequency=5 ebean.includeLabelInSql=true +ebean.slowQueryMillis=4 ebean.ddl.generate=true ebean.ddl.run=true ebean.ddl.header=-- Generated by ebean ${version} at ${timestamp}