From 8c6f8025e32f422857f0a29fd142c4306b658b9a Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Tue, 10 Mar 2020 13:54:42 -0700 Subject: [PATCH 1/9] HHH-13619 - Support for JPA's `size` function as a select expression - Fix to work on Oracle by removing "as" between table name and alias --- .../org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java index 4969a6af31..a8f868ea66 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java @@ -74,7 +74,7 @@ public class CollectionSizeNode extends SqlNode implements SelectExpression { final String sizeColumn = sizeColumns[0]; final StringBuilder buffer = new StringBuilder( "(select " ).append( sizeColumn ); - buffer.append( " from " ).append( collectionDescriptor.getTableName() ).append( " as " ).append( collectionTableAlias ); + buffer.append( " from " ).append( collectionDescriptor.getTableName() ).append( " " ).append( collectionTableAlias ); buffer.append( " where " ); boolean firstPass = true; From 486addab0cef2a9e886b615d35da0620133894d7 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 18 Mar 2020 16:06:15 +0000 Subject: [PATCH 2/9] HHH-13897 ResultSetProcessingContextImpl: no need to clear collections before discarding the reference to them --- .../exec/process/internal/ResultSetProcessingContextImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessingContextImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessingContextImpl.java index 8b9cfe8486..57bc45bc69 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessingContextImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessingContextImpl.java @@ -322,12 +322,10 @@ public class ResultSetProcessingContextImpl implements ResultSetProcessingContex createSubselects(); if ( hydratedEntityRegistrationList != null ) { - hydratedEntityRegistrationList.clear(); hydratedEntityRegistrationList = null; } if ( subselectLoadableEntityKeyMap != null ) { - subselectLoadableEntityKeyMap.clear(); subselectLoadableEntityKeyMap = null; } } From b35ccc8e37b5704ff4589be5b0cf7e89aedfacb9 Mon Sep 17 00:00:00 2001 From: Romain Moreau Date: Fri, 8 Nov 2019 13:56:19 +0100 Subject: [PATCH 3/9] HHH-13711: drop constraints enabled for H2 --- .../src/main/java/org/hibernate/dialect/H2Dialect.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index f36701b32c..73e3d39f75 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -435,10 +435,8 @@ public class H2Dialect extends Dialect { } @Override - public boolean dropConstraints() { - // We don't need to drop constraints before dropping tables, that just leads to error - // messages about missing tables when we don't have a schema in the database - return false; + public boolean supportsIfExistsAfterAlterTable() { + return true; } @Override From b5443deab3cff37826ab9a22e61995eb81bc3b97 Mon Sep 17 00:00:00 2001 From: romainmoreau <1763676+romainmoreau@users.noreply.github.com> Date: Sat, 8 Feb 2020 16:17:42 +0100 Subject: [PATCH 4/9] Drop constraints using CASCADE Co-Authored-By: William Cekan --- .../java/org/hibernate/dialect/H2Dialect.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 73e3d39f75..7e2a85d8bd 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -259,11 +259,6 @@ public class H2Dialect extends Dialect { return false; } - @Override - public boolean supportsIfExistsAfterTableName() { - return true; - } - @Override public boolean supportsIfExistsBeforeConstraintName() { return true; @@ -434,8 +429,25 @@ public class H2Dialect extends Dialect { return false; } + // Do not drop constraints explicitly, just do this by cascading instead. @Override - public boolean supportsIfExistsAfterAlterTable() { + public boolean dropConstraints() { + return false; + } + + @Override + public String getCascadeConstraintsString() { + return " CASCADE "; + } + + // CASCADE has to be AFTER IF EXISTS in case it's after the tablename + @Override + public boolean supportsIfExistsAfterTableName() { + return false; + } + + @Override + public boolean supportsIfExistsBeforeTableName() { return true; } From 3427bc8414b90910fe79b93a812e72bcc2f72398 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 6 Mar 2020 16:48:31 -0800 Subject: [PATCH 5/9] HHH-13891 : Added test --- .../test/proxy/FinalGetterSetterTest.java | 502 ++++++++++++++++++ 1 file changed, 502 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/proxy/FinalGetterSetterTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/proxy/FinalGetterSetterTest.java b/hibernate-core/src/test/java/org/hibernate/test/proxy/FinalGetterSetterTest.java new file mode 100644 index 0000000000..7f4c742b5e --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/proxy/FinalGetterSetterTest.java @@ -0,0 +1,502 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.proxy; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Version; + +import org.hibernate.Hibernate; +import org.hibernate.ObjectNotFoundException; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; +import org.junit.Test; + +import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * @author Gail Badner + */ +@TestForIssue( jiraKey = "HHH-13891" ) +public class FinalGetterSetterTest extends BaseNonConfigCoreFunctionalTestCase { + + @Test + public void testEntityWithFinalClass() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalClass.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalClass.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalClass entity = new EntityWithFinalClass(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalClass entity = session.load( EntityWithFinalClass.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Test + public void testEntityWithFinalIdGetter() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalIdGetter.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalIdGetter.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalIdGetter entity = new EntityWithFinalIdGetter(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalIdGetter entity = session.load( EntityWithFinalIdGetter.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Test + public void testEntityWithFinalIdSetter() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalIdSetter.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalIdSetter.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalIdSetter entity = new EntityWithFinalIdSetter(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalIdSetter entity = session.load( EntityWithFinalIdSetter.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Test + public void testEntityWithFinalVersionGetter() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalVersionGetter.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalVersionGetter.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalVersionGetter entity = new EntityWithFinalVersionGetter(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalVersionGetter entity = session.load( EntityWithFinalVersionGetter.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Test + public void testEntityWithFinalVersionSetter() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalVersionSetter.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalVersionSetter.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalVersionSetter entity = new EntityWithFinalVersionSetter(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalVersionSetter entity = session.load( EntityWithFinalVersionSetter.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Test + public void testEntityWithFinalPropertyGetter() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalPropertyGetter.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalPropertyGetter.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalPropertyGetter entity = new EntityWithFinalPropertyGetter(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalPropertyGetter entity = session.load( EntityWithFinalPropertyGetter.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Test + public void testEntityWithFinalPropertySetter() { + doInHibernate( this::sessionFactory, session -> { + assertNull( session.get( EntityWithFinalPropertySetter.class, 999 ) ); + }); + + try { + doInHibernate( this::sessionFactory, session -> { + session.load( EntityWithFinalPropertySetter.class, 999 ); + }); + fail( "Should have thrown ObjectNotFoundException" ); + } + catch (ObjectNotFoundException expected) { + } + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalPropertySetter entity = new EntityWithFinalPropertySetter(); + entity.id = 1; + entity.name = "An Entity"; + session.persist( entity ); + }); + + doInHibernate( this::sessionFactory, session -> { + final EntityWithFinalPropertySetter entity = session.load( EntityWithFinalPropertySetter.class, 1 ); + assertNotNull( entity ); + assertTrue( Hibernate.isInitialized( entity ) ); + }); + } + + @Override + public Class[] getAnnotatedClasses() { + return new Class[] { + EntityWithFinalClass.class, + EntityWithFinalIdGetter.class, + EntityWithFinalIdSetter.class, + EntityWithFinalVersionGetter.class, + EntityWithFinalVersionSetter.class, + EntityWithFinalPropertyGetter.class, + EntityWithFinalPropertySetter.class + }; + } + + @Entity( name = "EntityWithFinalClass") + public static final class EntityWithFinalClass { + + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public final int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @Entity( name = "EntityWithFinalIdGetter") + public static class EntityWithFinalIdGetter { + + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public final int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @Entity( name = "EntityWithFinalIdSetter") + public static class EntityWithFinalIdSetter { + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public int getId() { + return id; + } + + public final void setId(int id) { + this.id = id; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @Entity( name = "EntityWithFinalVersionGetter") + public static class EntityWithFinalVersionGetter { + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public final int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @Entity( name = "EntityWithFinalVersionSetter") + public static class EntityWithFinalVersionSetter { + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getVersion() { + return version; + } + + public final void setVersion(int version) { + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @Entity( name = "EntityWithFinalPropertyGetter") + public static class EntityWithFinalPropertyGetter { + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public final String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + @Entity( name = "EntityWithFinalPropertySetter") + public static class EntityWithFinalPropertySetter { + @Id + private int id; + + @Version + @Column(name = "ver") + private int version; + + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + + public String getName() { + return name; + } + + public final void setName(String name) { + this.name = name; + } + } +} From a54d657d98795e88b5541b9aa05a4621c9f5f1b5 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 6 Mar 2020 16:50:21 -0800 Subject: [PATCH 6/9] HHH-13891 : ProxyFactory should not be built if any ID or property getter/setter methods are final --- .../hibernate/internal/CoreMessageLogger.java | 12 ---------- .../proxy/pojo/ProxyFactoryHelper.java | 24 ++++++++++++------- .../tuple/entity/PojoEntityTuplizer.java | 8 +++++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java index 3b18c47b16..8b5d212d9a 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java @@ -344,12 +344,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Found mapping document in jar: %s", id = 109) void foundMappingDocument(String name); - @LogMessage(level = ERROR) - @Message(value = "Getters of lazy classes cannot be final: %s.%s", id = 112) - void gettersOfLazyClassesCannotBeFinal( - String entityName, - String name); - @LogMessage(level = WARN) @Message(value = "GUID identifier generated: %s", id = 113) void guidGenerated(String result); @@ -778,12 +772,6 @@ public interface CoreMessageLogger extends BasicLogger { @Message(value = "Sessions opened: %s", id = 242) void sessionsOpened(long sessionOpenCount); - @LogMessage(level = ERROR) - @Message(value = "Setters of lazy classes cannot be final: %s.%s", id = 243) - void settersOfLazyClassesCannotBeFinal( - String entityName, - String name); - @LogMessage(level = WARN) @Message(value = "@Sort not allowed for an indexed collection, annotation ignored.", id = 244) void sortAnnotationIndexedCollection(); diff --git a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/ProxyFactoryHelper.java b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/ProxyFactoryHelper.java index af9a3d7e3b..4f64fc6bb9 100644 --- a/hibernate-core/src/main/java/org/hibernate/proxy/pojo/ProxyFactoryHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/proxy/pojo/ProxyFactoryHelper.java @@ -11,6 +11,7 @@ import java.lang.reflect.Modifier; import java.util.Iterator; import java.util.Set; +import org.hibernate.HibernateException; import org.hibernate.MappingException; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; @@ -84,14 +85,21 @@ public final class ProxyFactoryHelper { Class clazz = persistentClass.getMappedClass(); while ( properties.hasNext() ) { Property property = (Property) properties.next(); - Method method = property.getGetter( clazz ).getMethod(); - if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { - LOG.gettersOfLazyClassesCannotBeFinal( persistentClass.getEntityName(), property.getName() ); - } - method = property.getSetter( clazz ).getMethod(); - if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { - LOG.settersOfLazyClassesCannotBeFinal( persistentClass.getEntityName(), property.getName() ); - } + validateGetterSetterMethodProxyability( "Getter", property.getGetter( clazz ).getMethod() ); + validateGetterSetterMethodProxyability( "Setter", property.getSetter( clazz ).getMethod() ); + } + } + + public static void validateGetterSetterMethodProxyability(String getterOrSetter, Method method ) { + if ( method != null && Modifier.isFinal( method.getModifiers() ) ) { + throw new HibernateException( + String.format( + "%s methods of lazy classes cannot be final: %s#%s", + getterOrSetter, + method.getDeclaringClass().getName(), + method.getName() + ) + ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java index ea4fa1c8b6..623c95d781 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java @@ -88,13 +88,17 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { final Set proxyInterfaces = ProxyFactoryHelper.extractProxyInterfaces( persistentClass, entityName ); - ProxyFactoryHelper.validateProxyability( persistentClass ); - Method proxyGetIdentifierMethod = ProxyFactoryHelper.extractProxyGetIdentifierMethod( idGetter, proxyInterface ); Method proxySetIdentifierMethod = ProxyFactoryHelper.extractProxySetIdentifierMethod( idSetter, proxyInterface ); ProxyFactory pf = buildProxyFactoryInternal( persistentClass, idGetter, idSetter ); try { + + ProxyFactoryHelper.validateGetterSetterMethodProxyability( "Getter", proxyGetIdentifierMethod ); + ProxyFactoryHelper.validateGetterSetterMethodProxyability( "Setter", proxySetIdentifierMethod ); + + ProxyFactoryHelper.validateProxyability( persistentClass ); + pf.postInstantiate( entityName, mappedClass, From caded6cd40877e082bcd93e8a20ce70a969efe90 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 26 Mar 2020 20:59:55 -0700 Subject: [PATCH 7/9] HHH-13910 : Added and corrected tests --- .../internal/StandardDialectResolverTest.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java b/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java index 61e59895dd..055bca8ec7 100644 --- a/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java +++ b/hibernate-core/src/test/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolverTest.java @@ -13,8 +13,8 @@ import org.junit.Test; import java.sql.SQLException; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; /** * Unit test of the {@link StandardDialectResolver} class. @@ -44,7 +44,7 @@ public class StandardDialectResolverTest extends BaseUnitTestCase { @Test public void testResolveDialectInternalForSQLServer2012() throws SQLException { - runSQLServerDialectTest( 11, SQLServer2008Dialect.class ); + runSQLServerDialectTest( 11, SQLServer2012Dialect.class ); } @Test @@ -93,7 +93,7 @@ public class StandardDialectResolverTest extends BaseUnitTestCase { @Test public void testResolveDialectInternalForPostgres92() throws SQLException { - runPostgresDialectTest( 9, 2, PostgreSQL9Dialect.class ); + runPostgresDialectTest( 9, 2, PostgreSQL92Dialect.class ); } @Test @@ -131,6 +131,17 @@ public class StandardDialectResolverTest extends BaseUnitTestCase { runMySQLDialectTest( 5, 7, MySQL57Dialect.class ); } + @Test + public void testResolveDialectInternalForMySQL6() throws SQLException { + runMySQLDialectTest( 6, 0, MySQL57Dialect.class ); + } + + @Test + public void testResolveDialectInternalForMySQL7() throws SQLException { + runMySQLDialectTest( 7, 0, MySQL57Dialect.class ); + } + + @Test public void testResolveDialectInternalForMySQL8() throws SQLException { runMySQLDialectTest( 8, 0, MySQL8Dialect.class ); @@ -188,8 +199,11 @@ public class StandardDialectResolverTest extends BaseUnitTestCase { String dbms = builder.toString(); assertNotNull( "Dialect for " + dbms + " should not be null", dialect ); - assertTrue( "Dialect for " + dbms + " should be " - + expectedDialect.getSimpleName(), - expectedDialect.isInstance( dialect ) ); + // Make sure to test that the actual dialect class is as expected + // (not just an instance of the expected dialect. + assertEquals( "Dialect for " + dbms + " should be " + expectedDialect.getSimpleName(), + expectedDialect, + dialect.getClass() + ); } } From e1d2aecef75bef9e61c64964fbb2e0103dafff7d Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 26 Mar 2020 21:02:44 -0700 Subject: [PATCH 8/9] HHH-13910 : MySQL57Dialect selected by automatic dialect resolution when using MySQL 8.0 database --- .../src/main/java/org/hibernate/dialect/Database.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Database.java b/hibernate-core/src/main/java/org/hibernate/dialect/Database.java index ca4bfef6e4..3402ffacc1 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Database.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Database.java @@ -358,6 +358,14 @@ public enum Database { return new MySQL57Dialect(); } } + else if ( majorVersion < 8) { + // There is no MySQL 6 or 7. + // Adding this just in case. + return new MySQL57Dialect(); + } + else if ( majorVersion == 8 ) { + return new MySQL8Dialect(); + } return latestDialectInstance( this ); } From 5104c4b7f3b99e8a78236053ac26aa59ed82f301 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 26 Mar 2020 22:15:06 -0700 Subject: [PATCH 9/9] 5.4.13 --- changelog.txt | 32 ++++++++++++++++++++++++++++++++ gradle/base-information.gradle | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 9d96a63c5e..d812af7995 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,38 @@ Hibernate 5 Changelog Note: Please refer to JIRA to learn more about each issue. +Changes in 5.4.13.Final (March 26, 2020) +------------------------------------------------------------------------------------------------------------------------ + +https://hibernate.atlassian.net/projects/HHH/versions/31829/tab/release-report-done + +** Bug + * [HHH-13322] - Sequence increment is not correctly determined + * [HHH-13619] - size() does not work properly as select expression + * [HHH-13711] - H2 dialect not accurate for drop table since version 1.4.200 + * [HHH-13870] - Gradle plugin causes compile task to be always out of date + * [HHH-13875] - Optional one-to-one does not always join the associated entity table when querying + * [HHH-13876] - Fix an obvious bug in StandardStack implementation + * [HHH-13891] - ProxyFactory should not be built if any ID or property getter/setter methods are final + * [HHH-13910] - MySQL57Dialect selected by automatic dialect resolution when using MySQL 8.0 database + +** New Feature + * [HHH-13799] - JPA Criteria API support for Hibernate Spatial + +** Task + * [HHH-13874] - Deprecate relevant methods that are supposed to be removed in v6.0 + +** Improvement + * [HHH-13103] - Allow Hibernate Types to get access to the current configuration properties using constructor injection + * [HHH-13853] - Pass the merged Integration settings and Persistence Unit properties to buildBootstrapServiceRegistry + * [HHH-13855] - Remove unnecessary declaration of JtaManager in HibernatePersistenceProviderAdaptor + * [HHH-13872] - Make the Java Stream close the underlying ScrollableResultsIterator upon calling a terminal operation + * [HHH-13873] - IdTableHelper can skip opening a connection when there's no statements to execute + * [HHH-13878] - Increase the scope of some methods to make them accessible outside of Hibernate ORM + * [HHH-13879] - Slow query log should use System#nanoTime not System#currentTimeMillis + * [HHH-13897] - ResultSetProcessingContextImpl: no need to clear collections before discarding the reference to them + + Changes in 5.4.12.Final (February 13, 2020) ------------------------------------------------------------------------------------------------------------------------ diff --git a/gradle/base-information.gradle b/gradle/base-information.gradle index ea01514f87..66ba5ec004 100644 --- a/gradle/base-information.gradle +++ b/gradle/base-information.gradle @@ -8,7 +8,7 @@ apply plugin: 'base' ext { - ormVersion = new HibernateVersion( '5.4.13-SNAPSHOT', project ) + ormVersion = new HibernateVersion( '5.4.13.Final', project ) baselineJavaVersion = '1.8' jpaVersion = new JpaVersion('2.2') }