From e98aece1f85c5a3dfa199af816b351b5b338ba29 Mon Sep 17 00:00:00 2001 From: Moritz Becker Date: Mon, 20 Jul 2020 19:35:41 +0200 Subject: [PATCH] [#841] Apply requested changes --- .../impl/function/cast/DB2CastFunction.java | 24 +++++++------- .../jsonget/AbstractJsonGetFunction.java | 25 ++++++++++++--- .../function/jsonget/DB2JsonGetFunction.java | 16 +++------- .../jsonget/MSSQLJsonGetFunction.java | 14 +++----- .../jsonget/MySQL8JsonGetFunction.java | 14 +++----- .../jsonget/OracleJsonGetFunction.java | 14 +++----- .../jsonset/MSSQLJsonSetFunction.java | 14 +++----- .../jsonset/MySQL8JsonSetFunction.java | 32 ++++++++----------- .../jsonset/OracleJsonSetFunction.java | 32 ++++++++----------- .../testsuite/JsonGetAndSetTest.java | 24 -------------- .../src/test/resources/logging.properties | 2 +- .../src/test/resources/logging.properties | 2 +- 12 files changed, 83 insertions(+), 130 deletions(-) diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/cast/DB2CastFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/cast/DB2CastFunction.java index 5631f5d597..e47d76f9fb 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/cast/DB2CastFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/cast/DB2CastFunction.java @@ -26,11 +26,11 @@ */ public class DB2CastFunction extends CastFunction { - private final String[] clobReturningFunctions = new String[] { - "json_value", - "json_query" + private static final String[] CLOB_RETURNING_FUNCTIONS = new String[] { + "json_value(", + "json_query(" }; - private final String[] clobCompatibleCastTargetTypes = new String[] { + private static final String[] CLOB_COMPATIBLE_CAST_TARGET_TYPES = new String[] { "char", "varchar", "graphic", @@ -79,19 +79,21 @@ public String getCastExpression(String argument) { } } - private boolean isClobReturningFunction(String castSource) { - for (int i = 0; i < clobReturningFunctions.length; i++) { - if (castSource.toLowerCase().startsWith(clobReturningFunctions[i] + "(")) { + private static boolean isClobReturningFunction(String castSource) { + for (int i = 0; i < CLOB_RETURNING_FUNCTIONS.length; i++) { + if (castSource.toLowerCase().startsWith(CLOB_RETURNING_FUNCTIONS[i])) { return true; } } return false; } - private boolean isClobCompatibleCastTarget(String castTargetType) { - for (int i = 0; i < clobCompatibleCastTargetTypes.length; i++) { - if (castTargetType.equalsIgnoreCase(clobCompatibleCastTargetTypes[i]) || - castTargetType.toLowerCase().startsWith(clobCompatibleCastTargetTypes[i] + "(")) { + private static boolean isClobCompatibleCastTarget(String castTargetType) { + for (int i = 0; i < CLOB_COMPATIBLE_CAST_TARGET_TYPES.length; i++) { + if (castTargetType.toLowerCase().indexOf(CLOB_COMPATIBLE_CAST_TARGET_TYPES[i]) == 0 && + (castTargetType.length() == CLOB_COMPATIBLE_CAST_TARGET_TYPES[i].length() || + castTargetType.charAt(CLOB_COMPATIBLE_CAST_TARGET_TYPES[i].length()) == '(') + ) { return true; } } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/AbstractJsonGetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/AbstractJsonGetFunction.java index c67ebad19e..b67b3d88e7 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/AbstractJsonGetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/AbstractJsonGetFunction.java @@ -15,9 +15,13 @@ */ package com.blazebit.persistence.impl.function.jsonget; +import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; import com.blazebit.persistence.spi.JpqlFunction; +import java.util.ArrayList; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -51,19 +55,20 @@ public void render(FunctionRenderContext context) { protected abstract void render0(FunctionRenderContext context); - public static String toJsonPath(Object[] pathElements, int to, boolean quotePathElements) { + public static String toJsonPath(List pathElements, int to, boolean quotePathElements) { StringBuilder jsonPathBuilder = new StringBuilder("$"); for (int i = 0; i < to; i++) { - if (pathElements[i] instanceof Integer) { + Object currentPathElement = pathElements.get(i); + if (currentPathElement instanceof Integer) { jsonPathBuilder.append('['); - jsonPathBuilder.append((int) pathElements[i]); + jsonPathBuilder.append((int) currentPathElement); jsonPathBuilder.append(']'); } else { jsonPathBuilder.append('.'); if (quotePathElements) { jsonPathBuilder.append("\""); } - jsonPathBuilder.append((String) pathElements[i]); + jsonPathBuilder.append((String) currentPathElement); if (quotePathElements) { jsonPathBuilder.append("\""); } @@ -71,4 +76,16 @@ public static String toJsonPath(Object[] pathElements, int to, boolean quotePath } return jsonPathBuilder.toString(); } + + public static List retrieveJsonPathElements(FunctionRenderContext context, int pathStartOffset) { + List jsonPathElements = new ArrayList<>(context.getArgumentsSize() - pathStartOffset); + for (int i = pathStartOffset; i < context.getArgumentsSize(); i++) { + try { + jsonPathElements.add(Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i)))); + } catch (NumberFormatException e) { + jsonPathElements.add(JpqlFunctionUtil.unquoteDoubleQuotes(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i)))); + } + } + return jsonPathElements; + } } diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/DB2JsonGetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/DB2JsonGetFunction.java index 17349110e5..f1f8b60455 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/DB2JsonGetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/DB2JsonGetFunction.java @@ -15,9 +15,10 @@ */ package com.blazebit.persistence.impl.function.jsonget; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -26,16 +27,9 @@ public class DB2JsonGetFunction extends AbstractJsonGetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize()]; - jsonPathElements[0] = "val"; - for (int i = 1; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i] = JpqlFunctionUtil.unquoteDoubleQuotes(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } - } - String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.length, false); + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 1); + jsonPathElements.add(0, "val"); + String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.size(), false); context.addChunk("json_query(concat('{\"val\":', concat("); context.addArgument(0); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MSSQLJsonGetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MSSQLJsonGetFunction.java index 36e2fc7bec..c9403f0bd2 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MSSQLJsonGetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MSSQLJsonGetFunction.java @@ -15,9 +15,10 @@ */ package com.blazebit.persistence.impl.function.jsonget; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -26,15 +27,8 @@ public class MSSQLJsonGetFunction extends AbstractJsonGetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize() - 1]; - for (int i = 1; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i - 1] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i - 1] = JpqlFunctionUtil.unquoteDoubleQuotes(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } - } - String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.length, true); + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 1); + String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.size(), false); context.addChunk("coalesce(json_value("); context.addArgument(0); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MySQL8JsonGetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MySQL8JsonGetFunction.java index e74e2552e9..b0d43f1c94 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MySQL8JsonGetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/MySQL8JsonGetFunction.java @@ -15,9 +15,10 @@ */ package com.blazebit.persistence.impl.function.jsonget; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -26,15 +27,8 @@ public class MySQL8JsonGetFunction extends AbstractJsonGetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize() - 1]; - for (int i = 1; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i - 1] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i - 1] = JpqlFunctionUtil.unquoteDoubleQuotes(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } - } - String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.length, true); + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 1); + String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.size(), true); context.addChunk("json_unquote("); context.addChunk("nullif(json_extract("); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/OracleJsonGetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/OracleJsonGetFunction.java index 0dc1f80a86..f1f5a9d156 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/OracleJsonGetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonget/OracleJsonGetFunction.java @@ -15,9 +15,10 @@ */ package com.blazebit.persistence.impl.function.jsonget; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -26,15 +27,8 @@ public class OracleJsonGetFunction extends AbstractJsonGetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize() - 1]; - for (int i = 1; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i - 1] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i - 1] = JpqlFunctionUtil.unquoteDoubleQuotes(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } - } - String jsonPath = toJsonPath(jsonPathElements, jsonPathElements.length, true); + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 1); + String jsonPath = toJsonPath(jsonPathElements, jsonPathElements.size(), true); context.addChunk("coalesce(json_value("); context.addArgument(0); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MSSQLJsonSetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MSSQLJsonSetFunction.java index fe338c115e..1ee7d924a8 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MSSQLJsonSetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MSSQLJsonSetFunction.java @@ -16,9 +16,10 @@ package com.blazebit.persistence.impl.function.jsonset; import com.blazebit.persistence.impl.function.jsonget.AbstractJsonGetFunction; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -27,15 +28,8 @@ public class MSSQLJsonSetFunction extends AbstractJsonGetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize() - 2]; - for (int i = 2; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i - 2] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i - 2] = JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i)); - } - } - String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.length, true); + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 2); + String jsonPath = AbstractJsonGetFunction.toJsonPath(jsonPathElements, jsonPathElements.size(), true); context.addChunk("(select case when isjson(temp.val) = 0 then (case "); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MySQL8JsonSetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MySQL8JsonSetFunction.java index 7deb21ebc7..aee257dac1 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MySQL8JsonSetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/MySQL8JsonSetFunction.java @@ -16,9 +16,10 @@ package com.blazebit.persistence.impl.function.jsonset; import com.blazebit.persistence.impl.function.jsonget.AbstractJsonGetFunction; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -27,27 +28,20 @@ public class MySQL8JsonSetFunction extends AbstractJsonSetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize() - 2]; - for (int i = 2; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i - 2] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i - 2] = JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i)); - } - } + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 2); context.addChunk("(select "); context.addChunk("json_merge_patch("); context.addArgument(0); context.addChunk(", concat('"); - for (int i = 0; i < jsonPathElements.length; i++) { + for (int i = 0; i < jsonPathElements.size(); i++) { startJsonPathElement(context, jsonPathElements, i); } context.addChunk("', "); context.addChunk("temp.val"); context.addChunk(", '"); - for (int i = jsonPathElements.length - 1; i >= 0; i--) { + for (int i = jsonPathElements.size() - 1; i >= 0; i--) { endJsonPathElement(context, jsonPathElements, i); } context.addChunk("'))"); @@ -57,8 +51,8 @@ protected void render0(FunctionRenderContext context) { context.addChunk(")) temp(val))"); } - private void startJsonPathElement(FunctionRenderContext context, Object[] pathElems, int curIndex) { - Object pathElem = pathElems[curIndex]; + private void startJsonPathElement(FunctionRenderContext context, List pathElems, int curIndex) { + Object pathElem = pathElems.get(curIndex); if (pathElem instanceof Integer) { context.addChunk("[', "); @@ -80,7 +74,7 @@ private void startJsonPathElement(FunctionRenderContext context, Object[] pathEl context.addChunk(")"); context.addChunk(", ',', "); } - if (curIndex < pathElems.length - 1) { + if (curIndex < pathElems.size()) { context.addChunk("coalesce(json_merge_patch("); renderJsonGet(context, AbstractJsonGetFunction.toJsonPath(pathElems, curIndex + 1, true)); context.addChunk(", concat('"); @@ -94,17 +88,17 @@ private void startJsonPathElement(FunctionRenderContext context, Object[] pathEl } } - private void endJsonPathElement(FunctionRenderContext context, Object[] pathElems, int curIndex) { - Object pathElem = pathElems[curIndex]; + private void endJsonPathElement(FunctionRenderContext context, List pathElems, int curIndex) { + Object pathElem = pathElems.get(curIndex); if (pathElem instanceof Integer) { context.addChunk("'"); - if (curIndex < pathElems.length - 1) { + if (curIndex < pathElems.size() - 1) { context.addChunk(")), concat('"); - for (int i = curIndex + 1; i < pathElems.length; i++) { + for (int i = curIndex + 1; i < pathElems.size(); i++) { startJsonPathElement(context, pathElems, i); } context.addChunk("', temp.val, '"); - for (int i = pathElems.length - 1; i >= curIndex + 1; i--) { + for (int i = pathElems.size() - 1; i >= curIndex + 1; i--) { endJsonPathElement(context, pathElems, i); } context.addChunk("'))"); diff --git a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/OracleJsonSetFunction.java b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/OracleJsonSetFunction.java index 5844b41da7..baf9ef3f9b 100644 --- a/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/OracleJsonSetFunction.java +++ b/core/impl/src/main/java/com/blazebit/persistence/impl/function/jsonset/OracleJsonSetFunction.java @@ -16,9 +16,10 @@ package com.blazebit.persistence.impl.function.jsonset; import com.blazebit.persistence.impl.function.jsonget.AbstractJsonGetFunction; -import com.blazebit.persistence.impl.util.JpqlFunctionUtil; import com.blazebit.persistence.spi.FunctionRenderContext; +import java.util.List; + /** * @author Moritz Becker * @since 1.5.0 @@ -27,27 +28,20 @@ public class OracleJsonSetFunction extends AbstractJsonSetFunction { @Override protected void render0(FunctionRenderContext context) { - Object[] jsonPathElements = new Object[context.getArgumentsSize() - 2]; - for (int i = 2; i < context.getArgumentsSize(); i++) { - try { - jsonPathElements[i - 2] = Integer.parseInt(JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i))); - } catch (NumberFormatException e) { - jsonPathElements[i - 2] = JpqlFunctionUtil.unquoteSingleQuotes(context.getArgument(i)); - } - } + List jsonPathElements = AbstractJsonGetFunction.retrieveJsonPathElements(context, 2); context.addChunk("(select "); context.addChunk("json_mergepatch("); context.addArgument(0); context.addChunk(",'"); - for (int i = 0; i < jsonPathElements.length; i++) { + for (int i = 0; i < jsonPathElements.size(); i++) { startJsonPathElement(context, jsonPathElements, i); } context.addChunk("' || "); context.addChunk("column_value"); context.addChunk(" || '"); - for (int i = jsonPathElements.length - 1; i >= 0; i--) { + for (int i = jsonPathElements.size() - 1; i >= 0; i--) { endJsonPathElement(context, jsonPathElements, i); } context.addChunk("')"); @@ -57,8 +51,8 @@ protected void render0(FunctionRenderContext context) { context.addChunk(")))"); } - private void startJsonPathElement(FunctionRenderContext context, Object[] pathElems, int curIndex) { - Object pathElem = pathElems[curIndex]; + private void startJsonPathElement(FunctionRenderContext context, List pathElems, int curIndex) { + Object pathElem = pathElems.get(curIndex); if (pathElem instanceof Integer) { context.addChunk("[' || "); @@ -81,7 +75,7 @@ private void startJsonPathElement(FunctionRenderContext context, Object[] pathEl context.addChunk(pathElem.toString()); context.addChunk("+1, "); - if (curIndex < pathElems.length - 1) { + if (curIndex < pathElems.size() - 1) { context.addChunk("coalesce(json_mergepatch("); renderJsonGet(context, AbstractJsonGetFunction.toJsonPath(pathElems, curIndex + 1, true)); context.addChunk(",'"); @@ -95,17 +89,17 @@ private void startJsonPathElement(FunctionRenderContext context, Object[] pathEl } } - private void endJsonPathElement(FunctionRenderContext context, Object[] pathElems, int curIndex) { - Object pathElem = pathElems[curIndex]; + private void endJsonPathElement(FunctionRenderContext context, List pathElems, int curIndex) { + Object pathElem = pathElems.get(curIndex); if (pathElem instanceof Integer) { context.addChunk("'"); - if (curIndex < pathElems.length - 1) { + if (curIndex < pathElems.size() - 1) { context.addChunk("), '"); - for (int i = curIndex + 1; i < pathElems.length; i++) { + for (int i = curIndex + 1; i < pathElems.size(); i++) { startJsonPathElement(context, pathElems, i); } context.addChunk("' || column_value || '"); - for (int i = pathElems.length - 1; i >= curIndex + 1; i--) { + for (int i = pathElems.size() - 1; i >= curIndex + 1; i--) { endJsonPathElement(context, pathElems, i); } context.addChunk("')"); diff --git a/core/testsuite/src/test/java/com/blazebit/persistence/testsuite/JsonGetAndSetTest.java b/core/testsuite/src/test/java/com/blazebit/persistence/testsuite/JsonGetAndSetTest.java index acb7845ea8..dd66e1dc2b 100644 --- a/core/testsuite/src/test/java/com/blazebit/persistence/testsuite/JsonGetAndSetTest.java +++ b/core/testsuite/src/test/java/com/blazebit/persistence/testsuite/JsonGetAndSetTest.java @@ -55,14 +55,6 @@ protected Class[] getEntityClasses() { return new Class[] { JsonDocument.class }; } - @Parameterized.Parameters - public static Collection configurationPermutations() { - return Arrays.asList( - new Object[]{true}, - new Object[]{false} - ); - } - @Override public void setUpOnce() { cleanDatabase(); @@ -186,20 +178,4 @@ public void testJsonSetNull() throws JsonProcessingException { assertTrue(objectMapper.readTree((String) objectRootResult.get(0).get(1)).at("/K1/0/K2").isNull()); assertTrue(objectMapper.readTree((String) objectRootResult.get(0).get(2)).at("/K1/0").isNull()); } - - - @Test - @Category({ NoH2.class, NoSQLite.class, NoFirebird.class, NoMySQLOld.class, NoMSSQL.class, NoDB2.class }) - public void testJsonSetNoMssql() throws JsonProcessingException { - List objectRootResult = cbf.create(em, Tuple.class).from(JsonDocument.class, "d") - .select("d.content") - // json_set with non-existent path not supported for MSSQL and DB2 - .select("json_set(d.content, '2', 'K1', '2', 'K2')") - .select("json_set(d.content, '2', 'K1', '5', 'K2')") - .where("id").eq(1L) - .getResultList(); - assertEquals(1, objectRootResult.size()); - assertEquals(2, objectMapper.readTree((String) objectRootResult.get(0).get(1)).at("/K1/2/K2").intValue()); - assertEquals(2, objectMapper.readTree((String) objectRootResult.get(0).get(2)).at("/K1/5/K2").intValue()); - } } diff --git a/core/testsuite/src/test/resources/logging.properties b/core/testsuite/src/test/resources/logging.properties index 749e05191d..4504e3764f 100644 --- a/core/testsuite/src/test/resources/logging.properties +++ b/core/testsuite/src/test/resources/logging.properties @@ -21,7 +21,7 @@ handlers = java.util.logging.ConsoleHandler org.hibernate.level = SEVERE org.hibernate.tool.hbm2ddl.level = OFF org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl.level = ALL -org.hibernate.SQL.level = ALL +#org.hibernate.SQL.level = ALL #org.hibernate.type.descriptor.sql.level = ALL #org.hibernate.tool.hbm2ddl.level = ALL #org.hibernate.pretty.level = ALL diff --git a/jpa-criteria/testsuite/src/test/resources/logging.properties b/jpa-criteria/testsuite/src/test/resources/logging.properties index be91f682cf..8a9481332d 100644 --- a/jpa-criteria/testsuite/src/test/resources/logging.properties +++ b/jpa-criteria/testsuite/src/test/resources/logging.properties @@ -21,7 +21,7 @@ handlers = java.util.logging.ConsoleHandler org.hibernate.level = SEVERE org.hibernate.tool.hbm2ddl.level = OFF org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl.level = ALL -org.hibernate.SQL.level = ALL +#org.hibernate.SQL.level = ALL #org.hibernate.type.descriptor.sql.level = ALL #org.hibernate.tool.hbm2ddl.level = ALL #org.hibernate.pretty.level = ALL