From 36ec08ed0ea43587e41867fa4e4f531b0be46667 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 21 May 2024 13:59:57 +0200 Subject: [PATCH 1/2] Add missing hints for hibernate-orm types referenced from ValueGenerationType. Closes: #323 --- .../6.5.0.Final/reflect-config.json | 40 +++++++++++++++++++ .../IdentifierGeneratorTest.java | 21 ++++++++++ 2 files changed, 61 insertions(+) diff --git a/metadata/org.hibernate.orm/hibernate-core/6.5.0.Final/reflect-config.json b/metadata/org.hibernate.orm/hibernate-core/6.5.0.Final/reflect-config.json index e45c07b9a..52133ef4b 100644 --- a/metadata/org.hibernate.orm/hibernate-core/6.5.0.Final/reflect-config.json +++ b/metadata/org.hibernate.orm/hibernate-core/6.5.0.Final/reflect-config.json @@ -518,6 +518,46 @@ "name":"org.hibernate.event.spi.EventType", "allDeclaredFields":true }, +{ + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.CurrentTimestampGeneration", + "queryAllDeclaredConstructors":true, + "methods":[ + {"name":"","parameterTypes":["org.hibernate.annotations.CreationTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.CurrentTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.UpdateTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] } + ] +}, +{ + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.GeneratedAlwaysGeneration", + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.GeneratedGeneration", + "queryAllDeclaredConstructors":true, + "methods":[ + {"name":"","parameterTypes":["org.hibernate.annotations.Generated"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.GenerationTime"] } + ] +}, +{ + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.SourceGeneration", + "queryAllDeclaredConstructors":true, + "methods":[ + {"name":"","parameterTypes":["org.hibernate.annotations.Source","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.SourceType","java.lang.Class","org.hibernate.generator.GeneratorCreationContext"] } + ] +}, +{ + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.TenantIdGeneration", + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":["org.hibernate.annotations.TenantId","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }] +}, { "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, "name":"org.hibernate.id.Assigned", diff --git a/tests/src/org.hibernate.orm/hibernate-core/6.5.0.Final/src/test/java/org_hibernate_orm/hibernate_core/IdentifierGeneratorTest.java b/tests/src/org.hibernate.orm/hibernate-core/6.5.0.Final/src/test/java/org_hibernate_orm/hibernate_core/IdentifierGeneratorTest.java index 9ea3362c1..71cbcf92b 100644 --- a/tests/src/org.hibernate.orm/hibernate-core/6.5.0.Final/src/test/java/org_hibernate_orm/hibernate_core/IdentifierGeneratorTest.java +++ b/tests/src/org.hibernate.orm/hibernate-core/6.5.0.Final/src/test/java/org_hibernate_orm/hibernate_core/IdentifierGeneratorTest.java @@ -26,6 +26,14 @@ public class IdentifierGeneratorTest { org.hibernate.id.ForeignGenerator.class }; + private static final Class[] VALUE_GENERATION_TYPE_GENERATORS_FROM_ANNOTATIONS = new Class[]{ + org.hibernate.generator.internal.CurrentTimestampGeneration.class, + org.hibernate.generator.internal.GeneratedAlwaysGeneration.class, + org.hibernate.generator.internal.GeneratedGeneration.class, + org.hibernate.generator.internal.SourceGeneration.class, + org.hibernate.generator.internal.TenantIdGeneration.class + }; + @Test public void testIdentifierGenerators() throws Exception { for (Class clazz : identifierGenerators) { @@ -33,4 +41,17 @@ public void testIdentifierGenerators() throws Exception { assertThat(constructor).isNotNull(); } } + + /** + * {@link org.hibernate.annotations.ValueGenerationType#generatedBy()} may hold types reflectively instantiated. + * This uses a list of those to make sure hints are present. + */ + @Test + public void testValueGenerationTypes() throws Exception { + for (Class clazz : VALUE_GENERATION_TYPE_GENERATORS_FROM_ANNOTATIONS) { + for (Constructor ctor : clazz.getDeclaredConstructors()) { + assertThat(clazz.getConstructor(ctor.getParameterTypes())).isEqualTo(ctor); + } + } + } } From b0dcfc5fd130979f0241718abc3958bb7ccc0948 Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 21 May 2024 14:00:22 +0200 Subject: [PATCH 2/2] Back port hints to metadata for hibernate 6.2 See: #323 --- .../6.2.0.Final/reflect-config.json | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/metadata/org.hibernate.orm/hibernate-core/6.2.0.Final/reflect-config.json b/metadata/org.hibernate.orm/hibernate-core/6.2.0.Final/reflect-config.json index 805d5eb93..73b7acf35 100644 --- a/metadata/org.hibernate.orm/hibernate-core/6.2.0.Final/reflect-config.json +++ b/metadata/org.hibernate.orm/hibernate-core/6.2.0.Final/reflect-config.json @@ -453,6 +453,46 @@ "name":"org.hibernate.event.spi.EventType", "allDeclaredFields":true }, + { + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.CurrentTimestampGeneration", + "queryAllDeclaredConstructors":true, + "methods":[ + {"name":"","parameterTypes":["org.hibernate.annotations.CreationTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.CurrentTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.UpdateTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] } + ] + }, + { + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.GeneratedAlwaysGeneration", + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":[] }] + }, + { + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.GeneratedGeneration", + "queryAllDeclaredConstructors":true, + "methods":[ + {"name":"","parameterTypes":["org.hibernate.annotations.Generated"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.GenerationTime"] } + ] + }, + { + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.SourceGeneration", + "queryAllDeclaredConstructors":true, + "methods":[ + {"name":"","parameterTypes":["org.hibernate.annotations.Source","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }, + {"name":"","parameterTypes":["org.hibernate.annotations.SourceType","java.lang.Class","org.hibernate.generator.GeneratorCreationContext"] } + ] + }, + { + "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, + "name":"org.hibernate.generator.internal.TenantIdGeneration", + "queryAllDeclaredConstructors":true, + "methods":[{"name":"","parameterTypes":["org.hibernate.annotations.TenantId","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] }] + }, { "condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"}, "name":"org.hibernate.id.Assigned",