Skip to content

Commit

Permalink
Add missing hints for hibernate-orm types referenced from ValueGenera…
Browse files Browse the repository at this point in the history
…tionType.

Closes: oracle#323
  • Loading branch information
christophstrobl committed May 21, 2024
1 parent a4d08f5 commit 36ec08e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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":"<init>","parameterTypes":["org.hibernate.annotations.CreationTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] },
{"name":"<init>","parameterTypes":["org.hibernate.annotations.CurrentTimestamp","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] },
{"name":"<init>","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":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"},
"name":"org.hibernate.generator.internal.GeneratedGeneration",
"queryAllDeclaredConstructors":true,
"methods":[
{"name":"<init>","parameterTypes":["org.hibernate.annotations.Generated"] },
{"name":"<init>","parameterTypes":["org.hibernate.annotations.GenerationTime"] }
]
},
{
"condition":{"typeReachable":"org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory"},
"name":"org.hibernate.generator.internal.SourceGeneration",
"queryAllDeclaredConstructors":true,
"methods":[
{"name":"<init>","parameterTypes":["org.hibernate.annotations.Source","java.lang.reflect.Member","org.hibernate.generator.GeneratorCreationContext"] },
{"name":"<init>","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":"<init>","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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,32 @@ 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) {
Constructor constructor = clazz.getConstructor();
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);
}
}
}
}

0 comments on commit 36ec08e

Please sign in to comment.