diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 62d4c0535..e708b1c02 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index be52383ef..442d9132e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index fbd7c5158..4f906e0c8 100755 --- a/gradlew +++ b/gradlew @@ -130,7 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index a9f778a7a..ac1b06f93 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,21 +64,6 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line @@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java index 8c00db2a8..2a279b55e 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentifierGenerationTypeTest.java @@ -79,7 +79,7 @@ public void longIdentifierWithStageAPI(TestContext context) { @Test public void shortIdentifierWithStageAPI(TestContext context) { ShortEntity entityA = new ShortEntity( "Short A" ); - ShortEntity entityB = new ShortEntity( "Long B" ); + ShortEntity entityB = new ShortEntity( "Short B" ); Stage.Session session = openSession(); test( context, session @@ -98,7 +98,6 @@ public void shortIdentifierWithStageAPI(TestContext context) { * Mutiny API tests */ - @Test public void integerIdentifierWithMutinyAPI(TestContext context) { IntegerEntity entityA = new IntegerEntity( "Integer A" ); @@ -138,7 +137,7 @@ public void longIdentifierWithMutinyAPI(TestContext context) { @Test public void shortIdentifierWithMutinyAPI(TestContext context) { ShortEntity entityA = new ShortEntity( "Short A" ); - ShortEntity entityB = new ShortEntity( "Long B" ); + ShortEntity entityB = new ShortEntity( "Short B" ); Mutiny.Session session = openMutinySession(); test( context, session diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java new file mode 100644 index 000000000..2c29500a8 --- /dev/null +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UUIDAsBinaryType.java @@ -0,0 +1,176 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive; + +import java.util.Objects; +import java.util.UUID; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +import org.hibernate.cfg.Configuration; +import org.hibernate.reactive.mutiny.Mutiny; +import org.hibernate.reactive.testing.DatabaseSelectionRule; + +import org.junit.Rule; +import org.junit.Test; + +import io.vertx.ext.unit.TestContext; + +import static java.util.Arrays.asList; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MARIA; +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; +import static org.hibernate.reactive.testing.DatabaseSelectionRule.runOnlyFor; +import static org.hibernate.reactive.testing.DatabaseSelectionRule.skipTestsFor; + +public abstract class UUIDAsBinaryType extends BaseReactiveTest { + + public static class ForMySQLandMariaDBTest extends UUIDAsBinaryType { + // There's an issue querying for Binary types if the size of the column is different from + // the size of the parameter: see https://github.com/hibernate/hibernate-reactive/issues/678 + @Rule + public DatabaseSelectionRule rule = runOnlyFor( MYSQL, MARIA ); + + @Override + protected Configuration constructConfiguration() { + Configuration configuration = super.constructConfiguration(); + configuration.addAnnotatedClass( ExactSizeUUIDEntity.class ); + return configuration; + } + + @Test + public void exactSize(TestContext context) { + ExactSizeUUIDEntity entityA = new ExactSizeUUIDEntity( "Exact Size A" ); + ExactSizeUUIDEntity entityB = new ExactSizeUUIDEntity( "Exact Size B" ); + + Mutiny.Session session = openMutinySession(); + test( context, session + .persistAll( entityA, entityB ) + .call( session::flush ) + .invoke( () -> context.assertNotEquals( entityA.id, entityB.id ) ) + .chain( () -> openMutinySession().find( ExactSizeUUIDEntity.class, entityA.id, entityB.id ) ) + .invoke( list -> { + context.assertEquals( list.size(), 2 ); + context.assertTrue( list.containsAll( asList( entityA, entityB ) ) ); + } ) + ); + } + + @Entity + private static class ExactSizeUUIDEntity { + + @Id + @GeneratedValue + @Column(columnDefinition = "binary(16)") + UUID id; + + @Column(unique = true) + String name; + + public ExactSizeUUIDEntity() { + } + + public ExactSizeUUIDEntity(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if ( this == o ) { + return true; + } + if ( o == null || getClass() != o.getClass() ) { + return false; + } + ExactSizeUUIDEntity that = (ExactSizeUUIDEntity) o; + return Objects.equals( name, that.name ); + } + + @Override + public int hashCode() { + return Objects.hash( name ); + } + + @Override + public String toString() { + return id + ":" + name; + } + } + + } + + public static class ForOtherDbsTest extends UUIDAsBinaryType { + + @Rule + public DatabaseSelectionRule rule = skipTestsFor( MYSQL, MARIA ); + + @Override + protected Configuration constructConfiguration() { + Configuration configuration = super.constructConfiguration(); + configuration.addAnnotatedClass( UUIDEntity.class ); + return configuration; + } + + @Test + public void uuidIdentifierWithMutinyAPI(TestContext context) { + UUIDEntity entityA = new UUIDEntity( "UUID A" ); + UUIDEntity entityB = new UUIDEntity( "UUID B" ); + + Mutiny.Session session = openMutinySession(); + test( context, session + .persistAll( entityA, entityB ) + .call( session::flush ) + .invoke( () -> context.assertNotEquals( entityA.id, entityB.id ) ) + .chain( () -> openMutinySession().find( UUIDEntity.class, entityA.id, entityB.id ) ) + .invoke( list -> { + context.assertEquals( list.size(), 2 ); + context.assertTrue( list.containsAll( asList( entityA, entityB ) ) ); + } ) + ); + } + + @Entity + private static class UUIDEntity { + + @Id + @GeneratedValue + UUID id; + + @Column(unique = true) + String name; + + public UUIDEntity() { + } + + public UUIDEntity(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if ( this == o ) { + return true; + } + if ( o == null || getClass() != o.getClass() ) { + return false; + } + UUIDEntity that = (UUIDEntity) o; + return Objects.equals( name, that.name ); + } + + @Override + public int hashCode() { + return Objects.hash( name ); + } + + @Override + public String toString() { + return id + ":" + name; + } + } + } +}