From c96357377b43c5a5081eafe290b5b40416041e79 Mon Sep 17 00:00:00 2001 From: Marcus Dunn <51931484+MarcusDunn@users.noreply.github.com> Date: Fri, 4 Nov 2022 11:56:48 -0700 Subject: [PATCH 1/5] Added platforms to BOM fixes #2884 I'm a complete maven (especially bom) novice - but thought I could take a stab at making the change. I also see you auto generate these with an action, is there anything needed there? Feel free to completely disregard if this or the issue itself is way off the mark. --- ebean-bom/pom.xml | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index a17609672..43bb2f5f0 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -190,6 +190,92 @@ ebean-redis 13.10.2-SNAPSHOT + + + + + io.ebean + ebean-all + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-clickhouse + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-db2 + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-h2 + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-hana + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-hsqldb + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-mariadb + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-mysql + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-nuodb + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-oracle + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-postgres + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-sqlanywhere + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-sqlite + 13.10.2-SNAPSHOT + + + + io.ebean + ebean-sqlserver + 13.10.2-SNAPSHOT + From 14dddb486648303bbe76de47684680646778a1eb Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Mon, 7 Nov 2022 22:25:32 +1300 Subject: [PATCH 2/5] #2774 - Postgres ANY / MultiValueSupport with byte[]/binary data Add Postgres specific support for binding an array of byte[] with ANY(?) which is used as with client side encryption where the bind values are implicitly converted to byte[]. Fixes Postgres specific failure running TestEncryptClientSide.java --- .../server/expression/InExpression.java | 8 ++----- .../platform/AbstractMultiValueBind.java | 22 +++---------------- .../persist/platform/MultiValueBind.java | 8 +++++++ 3 files changed, 13 insertions(+), 25 deletions(-) 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 7ec81687b..d0d89b9ff 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 @@ -95,7 +95,7 @@ public final class InExpression extends AbstractExpression implements IdInCommon public void prepareExpression(BeanQueryRequest request) { initBindValues(); if (bindValues.size() > 0) { - multiValueSupported = request.isMultiValueSupported((bindValues.get(0)).getClass()); + multiValueSupported = request.isMultiValueSupported(bindValues.get(0).getClass()); } } @@ -149,7 +149,6 @@ public final class InExpression extends AbstractExpression implements IdInCommon // if we have no property, we wrap them in a multi value wrapper. // later the binder will decide, which bind strategy to use. request.addBindValue(new MultiValueWrapper(values)); - } @Override @@ -164,7 +163,6 @@ public final class InExpression extends AbstractExpression implements IdInCommon } ElPropertyValue prop = getElProp(request); - if (prop != null) { if (prop.isAssocId()) { request.append(prop.assocIdInExpr(propName)); @@ -172,15 +170,13 @@ public final class InExpression extends AbstractExpression implements IdInCommon return; } if (prop.isDbEncrypted()) { - String dsql = prop.beanProperty().decryptProperty(propName); - request.append(dsql); + request.append(prop.beanProperty().decryptProperty(propName)); request.appendInExpression(not, bindValues); return; } } request.append(propName); request.appendInExpression(not, bindValues); - } /** diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/AbstractMultiValueBind.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/AbstractMultiValueBind.java index 18d41b757..5dd334ac5 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/AbstractMultiValueBind.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/AbstractMultiValueBind.java @@ -7,25 +7,7 @@ import io.ebeaninternal.server.bind.DataBind; import java.sql.SQLException; import java.util.Collection; -import static java.sql.Types.BIGINT; -import static java.sql.Types.BIT; -import static java.sql.Types.BOOLEAN; -import static java.sql.Types.CHAR; -import static java.sql.Types.DATE; -import static java.sql.Types.DECIMAL; -import static java.sql.Types.DOUBLE; -import static java.sql.Types.FLOAT; -import static java.sql.Types.INTEGER; -import static java.sql.Types.NCHAR; -import static java.sql.Types.NUMERIC; -import static java.sql.Types.NVARCHAR; -import static java.sql.Types.REAL; -import static java.sql.Types.SMALLINT; -import static java.sql.Types.TIMESTAMP; -import static java.sql.Types.TIMESTAMP_WITH_TIMEZONE; -import static java.sql.Types.TIME_WITH_TIMEZONE; -import static java.sql.Types.TINYINT; -import static java.sql.Types.VARCHAR; +import static java.sql.Types.*; /** * Base MultiValueBind for platform specific support. @@ -86,6 +68,8 @@ abstract class AbstractMultiValueBind extends MultiValueBind { case ExtraDbTypes.UUID: // Postgres cast to uuid[] case ExtraDbTypes.INET: // Postgres cast to inet[] return "varchar"; + case VARBINARY: + return "bytea"; default: return null; diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java index db47defcf..aca6ea2b1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java @@ -17,6 +17,14 @@ public class MultiValueBind { } Object[] toArray(Collection values, ScalarType type) { + if (type.binary()) { + byte[][] array = new byte[values.size()][]; + int i = 0; + for (Object value : values) { + array[i++] = (byte[])type.toJdbcType(value); + } + return array; + } Object[] array = new Object[values.size()]; int i = 0; for (Object value : values) { From 8966faeb7e5f0c1329a1719fca3c90c9c06fc3d1 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2022 09:33:09 +1300 Subject: [PATCH 3/5] #2774 - Postgres ANY / MultiValueSupport with byte[]/binary data Tidy up MultiValueBind.toArray() only --- .../server/persist/platform/MultiValueBind.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java index aca6ea2b1..941614ec1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/platform/MultiValueBind.java @@ -17,15 +17,7 @@ public class MultiValueBind { } Object[] toArray(Collection values, ScalarType type) { - if (type.binary()) { - byte[][] array = new byte[values.size()][]; - int i = 0; - for (Object value : values) { - array[i++] = (byte[])type.toJdbcType(value); - } - return array; - } - Object[] array = new Object[values.size()]; + Object[] array = type.binary() ? new byte[values.size()][] : new Object[values.size()]; int i = 0; for (Object value : values) { array[i++] = type.toJdbcType(value); From b1bba9da5d1f98e33ca2a962132237fe233fda4f Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2022 11:12:46 +1300 Subject: [PATCH 4/5] #2774 - Tidy InExpression adding check and block for prop != null wrt prop.isDbEncrypted() and prop.isLocalEncrypted() --- .../server/expression/InExpression.java | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) 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 d0d89b9ff..127f849e9 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 @@ -14,17 +14,13 @@ import java.util.*; public final class InExpression extends AbstractExpression implements IdInCommon { - private final boolean not; - /** * Set to true when adding "1=1" predicate (due to null or empty sourceValues). */ private final boolean empty; - + private final boolean not; private final Collection sourceValues; - private List bindValues; - private boolean multiValueSupported; InExpression(String propertyName, Collection sourceValues, boolean not) { @@ -117,7 +113,6 @@ public final class InExpression extends AbstractExpression implements IdInCommon } } ElPropertyValue prop = getElProp(request); - List values = bindValues; if (prop != null && prop.isAssocId()) { values = new ArrayList<>(); @@ -132,22 +127,22 @@ public final class InExpression extends AbstractExpression implements IdInCommon if (values.isEmpty()) { // nothing in in-query return; - } else if (prop.isDbEncrypted()) { - // bind the key as well as the value - String encryptKey = prop.beanProperty().encryptKey().getStringValue(); - request.addBindEncryptKey(encryptKey); - } else if (prop.isLocalEncrypted()) { - List encValues = new ArrayList<>(values.size()); - for (Object value : values) { - encValues.add(prop.localEncrypt(value)); - } - // this is most likely binary garbage, so don't add it to the bind log - request.addBindEncryptKey(new MultiValueWrapper(encValues)); - return; } - - // if we have no property, we wrap them in a multi value wrapper. - // later the binder will decide, which bind strategy to use. + if (prop != null) { + if (prop.isDbEncrypted()) { + // bind the key as well as the value + request.addBindEncryptKey(prop.beanProperty().encryptKey().getStringValue()); + } else if (prop.isLocalEncrypted()) { + List encValues = new ArrayList<>(values.size()); + for (Object value : values) { + encValues.add(prop.localEncrypt(value)); + } + // this is most likely binary garbage, so don't add it to the bind log + request.addBindEncryptKey(new MultiValueWrapper(encValues)); + return; + } + } + // wrap in a multi value wrapper, later the binder will decide the bind strategy to use request.addBindValue(new MultiValueWrapper(values)); } From 72f1ab18ccf46feedfa535ba06933f22fb3510a6 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 8 Nov 2022 14:16:12 +1300 Subject: [PATCH 5/5] No effective change - rename parameter names only --- .../ebeaninternal/server/bind/DataBind.java | 71 +++++++++---------- .../bind/capture/BindCaptureStatement.java | 64 ++++++++--------- .../BasePlatformArrayTypeFactoryTest.java | 4 +- 3 files changed, 68 insertions(+), 71 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/bind/DataBind.java b/ebean-core/src/main/java/io/ebeaninternal/server/bind/DataBind.java index 8ca702c29..3c4c1aedb 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/bind/DataBind.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/bind/DataBind.java @@ -115,88 +115,88 @@ public class DataBind implements DataBinder { } @Override - public void setString(String s) throws SQLException { - pstmt.setString(++pos, s); + public void setString(String value) throws SQLException { + pstmt.setString(++pos, value); } @Override - public final void setInt(int i) throws SQLException { - pstmt.setInt(++pos, i); + public final void setInt(int value) throws SQLException { + pstmt.setInt(++pos, value); } @Override - public final void setLong(long i) throws SQLException { - pstmt.setLong(++pos, i); + public final void setLong(long value) throws SQLException { + pstmt.setLong(++pos, value); } @Override - public final void setShort(short i) throws SQLException { - pstmt.setShort(++pos, i); + public final void setShort(short value) throws SQLException { + pstmt.setShort(++pos, value); } @Override - public final void setFloat(float i) throws SQLException { - pstmt.setFloat(++pos, i); + public final void setFloat(float value) throws SQLException { + pstmt.setFloat(++pos, value); } @Override - public final void setDouble(double i) throws SQLException { - pstmt.setDouble(++pos, i); + public final void setDouble(double value) throws SQLException { + pstmt.setDouble(++pos, value); } @Override - public final void setBigDecimal(BigDecimal v) throws SQLException { - pstmt.setBigDecimal(++pos, v); + public final void setBigDecimal(BigDecimal value) throws SQLException { + pstmt.setBigDecimal(++pos, value); } @Override - public final void setDate(java.sql.Date v) throws SQLException { + public final void setDate(java.sql.Date value) throws SQLException { Calendar timeZone = dataTimeZone.getTimeComponentTimeZone(); if (timeZone != null) { - pstmt.setDate(++pos, v, timeZone); + pstmt.setDate(++pos, value, timeZone); } else { - pstmt.setDate(++pos, v); + pstmt.setDate(++pos, value); } } @Override - public final void setTimestamp(Timestamp v) throws SQLException { + public final void setTimestamp(Timestamp value) throws SQLException { Calendar timeZone = dataTimeZone.getTimeZone(); if (timeZone != null) { - pstmt.setTimestamp(++pos, v, timeZone); + pstmt.setTimestamp(++pos, value, timeZone); } else { - pstmt.setTimestamp(++pos, v); + pstmt.setTimestamp(++pos, value); } } @Override - public final void setTime(Time v) throws SQLException { + public final void setTime(Time value) throws SQLException { Calendar timeZone = dataTimeZone.getTimeComponentTimeZone(); if (timeZone != null) { - pstmt.setTime(++pos, v, timeZone); + pstmt.setTime(++pos, value, timeZone); } else { - pstmt.setTime(++pos, v); + pstmt.setTime(++pos, value); } } @Override - public void setBoolean(boolean v) throws SQLException { - pstmt.setBoolean(++pos, v); + public void setBoolean(boolean value) throws SQLException { + pstmt.setBoolean(++pos, value); } @Override - public void setBytes(byte[] v) throws SQLException { - pstmt.setBytes(++pos, v); + public void setBytes(byte[] value) throws SQLException { + pstmt.setBytes(++pos, value); } @Override - public void setByte(byte v) throws SQLException { - pstmt.setByte(++pos, v); + public void setByte(byte value) throws SQLException { + pstmt.setByte(++pos, value); } @Override - public void setChar(char v) throws SQLException { - pstmt.setString(++pos, String.valueOf(v)); + public void setChar(char value) throws SQLException { + pstmt.setString(++pos, String.valueOf(value)); } @Override @@ -215,20 +215,17 @@ public class DataBind implements DataBinder { @Override public void setBlob(byte[] bytes) throws SQLException { - ByteArrayInputStream is = new ByteArrayInputStream(bytes); - pstmt.setBinaryStream(++pos, is, bytes.length); + pstmt.setBinaryStream(++pos, new ByteArrayInputStream(bytes), bytes.length); } @Override public void setClob(String content) throws SQLException { - Reader reader = new StringReader(content); - pstmt.setCharacterStream(++pos, reader, content.length()); + pstmt.setCharacterStream(++pos, new StringReader(content), content.length()); } @Override public void setArray(String arrayType, Object[] elements) throws SQLException { - Array array = connection.createArrayOf(arrayType, elements); - pstmt.setArray(++pos, array); + pstmt.setArray(++pos, connection.createArrayOf(arrayType, elements)); } } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/bind/capture/BindCaptureStatement.java b/ebean-core/src/main/java/io/ebeaninternal/server/bind/capture/BindCaptureStatement.java index 04ad70753..b5495a6c7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/bind/capture/BindCaptureStatement.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/bind/capture/BindCaptureStatement.java @@ -33,87 +33,87 @@ public final class BindCaptureStatement extends BindCaptureStatementBase impleme } @Override - public void setBoolean(int parameterIndex, boolean x) { - capture.add(new BindCaptureTypes.Boolean(parameterIndex, x)); + public void setBoolean(int parameterIndex, boolean value) { + capture.add(new BindCaptureTypes.Boolean(parameterIndex, value)); } @Override - public void setByte(int parameterIndex, byte x) { - capture.add(new BindCaptureTypes.Byte(parameterIndex, x)); + public void setByte(int parameterIndex, byte value) { + capture.add(new BindCaptureTypes.Byte(parameterIndex, value)); } @Override - public void setShort(int parameterIndex, short x) { - capture.add(new BindCaptureTypes.TShort(parameterIndex, x)); + public void setShort(int parameterIndex, short value) { + capture.add(new BindCaptureTypes.TShort(parameterIndex, value)); } @Override - public void setInt(int parameterIndex, int x) { - capture.add(new BindCaptureTypes.TInt(parameterIndex, x)); + public void setInt(int parameterIndex, int value) { + capture.add(new BindCaptureTypes.TInt(parameterIndex, value)); } @Override - public void setLong(int parameterIndex, long x) { - capture.add(new BindCaptureTypes.TLong(parameterIndex, x)); + public void setLong(int parameterIndex, long value) { + capture.add(new BindCaptureTypes.TLong(parameterIndex, value)); } @Override - public void setFloat(int parameterIndex, float x) { - capture.add(new BindCaptureTypes.TFloat(parameterIndex, x)); + public void setFloat(int parameterIndex, float value) { + capture.add(new BindCaptureTypes.TFloat(parameterIndex, value)); } @Override - public void setDouble(int parameterIndex, double x) { - capture.add(new BindCaptureTypes.TDouble(parameterIndex, x)); + public void setDouble(int parameterIndex, double value) { + capture.add(new BindCaptureTypes.TDouble(parameterIndex, value)); } @Override - public void setBigDecimal(int parameterIndex, BigDecimal x) { - capture.add(new BindCaptureTypes.TBigDecimal(parameterIndex, x)); + public void setBigDecimal(int parameterIndex, BigDecimal value) { + capture.add(new BindCaptureTypes.TBigDecimal(parameterIndex, value)); } @Override - public void setString(int parameterIndex, String x) { - capture.add(new BindCaptureTypes.TString(parameterIndex, x)); + public void setString(int parameterIndex, String value) { + capture.add(new BindCaptureTypes.TString(parameterIndex, value)); } @Override - public void setBytes(int parameterIndex, byte[] x) { - capture.add(new BindCaptureTypes.Bytes(parameterIndex, x)); + public void setBytes(int parameterIndex, byte[] value) { + capture.add(new BindCaptureTypes.Bytes(parameterIndex, value)); } @Override - public void setDate(int parameterIndex, Date x) { - capture.add(new BindCaptureTypes.TDate(parameterIndex, x)); + public void setDate(int parameterIndex, Date value) { + capture.add(new BindCaptureTypes.TDate(parameterIndex, value)); } @Override - public void setTime(int parameterIndex, Time x) { - capture.add(new BindCaptureTypes.TTime(parameterIndex, x)); + public void setTime(int parameterIndex, Time value) { + capture.add(new BindCaptureTypes.TTime(parameterIndex, value)); } @Override - public void setTimestamp(int parameterIndex, Timestamp x) { - capture.add(new BindCaptureTypes.TTimestamp(parameterIndex, x, null)); + public void setTimestamp(int parameterIndex, Timestamp value) { + capture.add(new BindCaptureTypes.TTimestamp(parameterIndex, value, null)); } @Override - public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) { - capture.add(new BindCaptureTypes.TTimestamp(parameterIndex, x, cal)); + public void setTimestamp(int parameterIndex, Timestamp value, Calendar cal) { + capture.add(new BindCaptureTypes.TTimestamp(parameterIndex, value, cal)); } @Override - public void setObject(int parameterIndex, Object x) { - capture.add(new BindCaptureTypes.TObject(parameterIndex, x)); + public void setObject(int parameterIndex, Object value) { + capture.add(new BindCaptureTypes.TObject(parameterIndex, value)); } @Override - public void setBinaryStream(int parameterIndex, InputStream x, int length) { + public void setBinaryStream(int parameterIndex, InputStream value, int length) { capture.add(new BindCaptureTypes.BinaryStream(parameterIndex)); } @Override - public void setCharacterStream(int parameterIndex, Reader reader, int length) { + public void setCharacterStream(int parameterIndex, Reader value, int length) { capture.add(new BindCaptureTypes.CharacterStream(parameterIndex)); } diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/type/BasePlatformArrayTypeFactoryTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/type/BasePlatformArrayTypeFactoryTest.java index aef8e4ece..4b4436487 100644 --- a/ebean-core/src/test/java/io/ebeaninternal/server/type/BasePlatformArrayTypeFactoryTest.java +++ b/ebean-core/src/test/java/io/ebeaninternal/server/type/BasePlatformArrayTypeFactoryTest.java @@ -65,8 +65,8 @@ class BasePlatformArrayTypeFactoryTest { } @Override - public void setString(String s) { - setEmptyString = "[]".equals(s); + public void setString(String value) { + setEmptyString = "[]".equals(value); } @Override