From 26e73937756de5781043f120905b71abe9398e5e Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 30 Nov 2022 21:30:45 +0100 Subject: [PATCH] HHH-15789 allow any InMemoryGenerator to generate ids --- .../annotations/GenericGenerator.java | 7 +- .../annotations/IdGeneratorType.java | 7 +- .../InFlightMetadataCollectorImpl.java | 8 +- .../model/IdentifierGeneratorDefinition.java | 175 ++++++++++++ .../org/hibernate/cfg/AnnotationBinder.java | 18 +- .../java/org/hibernate/cfg/BinderHelper.java | 184 +------------ .../cfg/annotations/PropertyBinder.java | 96 ++++--- .../spi/PersistentIdentifierBag.java | 2 +- .../dialect/temptable/TemporaryTable.java | 5 +- .../spi/SessionFactoryDelegatingImpl.java | 6 + .../engine/spi/SessionFactoryImplementor.java | 8 + .../internal/AbstractSaveEventListener.java | 4 +- .../internal/DefaultPersistEventListener.java | 2 +- .../org/hibernate/id/IdentifierGenerator.java | 31 ++- .../internal/IdentifierGeneratorUtil.java | 132 ++++++++++ .../StandardIdentifierGeneratorFactory.java | 2 +- .../internal/SessionFactoryImpl.java | 17 +- .../internal/StatelessSessionImpl.java | 2 +- .../java/org/hibernate/mapping/Component.java | 58 ++-- .../mapping/IdentifierGeneratorCreator.java | 4 +- .../java/org/hibernate/mapping/KeyValue.java | 49 ++-- .../org/hibernate/mapping/SimpleValue.java | 249 ++++++------------ .../AbstractCollectionPersister.java | 16 +- .../collection/CollectionPersister.java | 11 + .../entity/AbstractEntityPersister.java | 14 +- .../persister/entity/EntityPersister.java | 8 + .../entity/UnionSubclassEntityPersister.java | 2 +- .../query/sqm/internal/QuerySqmImpl.java | 7 +- .../internal/cte/CteInsertHandler.java | 14 +- .../temptable/InsertExecutionDelegate.java | 13 +- .../temptable/TableBasedInsertHandler.java | 8 +- .../sqm/sql/BaseSqmToSqlAstConverter.java | 21 +- .../tuple/AnnotationBasedGenerator.java | 23 +- .../tuple/AnnotationValueGeneration.java | 16 +- .../java/org/hibernate/tuple/Generator.java | 25 +- .../hibernate/tuple/IdentifierAttribute.java | 3 + .../hibernate/tuple/IdentifierProperty.java | 11 +- .../hibernate/tuple/InDatabaseGenerator.java | 20 +- .../hibernate/tuple/InMemoryGenerator.java | 13 +- .../org/hibernate/tuple/PropertyFactory.java | 3 +- .../org/hibernate/tuple/ValueGeneration.java | 8 +- .../tuple/entity/EntityMetamodel.java | 2 +- .../id/PooledHiLoSequenceIdentifierTest.java | 2 - .../BasicForcedTableSequenceTest.java | 4 +- .../enhanced/sequence/BasicSequenceTest.java | 8 +- .../idgen/enhanced/table/BasicTableTest.java | 4 +- .../UserDefinedGeneratorsTests.java | 1 - 47 files changed, 763 insertions(+), 560 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/id/factory/internal/IdentifierGeneratorUtil.java diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java b/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java index d2cc142ae1..f7a791c561 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/GenericGenerator.java @@ -6,7 +6,7 @@ */ package org.hibernate.annotations; -import org.hibernate.id.IdentifierGenerator; +import org.hibernate.tuple.InMemoryGenerator; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; @@ -74,12 +74,11 @@ public @interface GenericGenerator { */ String name(); /** - * The type of identifier generator, a class implementing - * {@link org.hibernate.id.IdentifierGenerator}. + * The type of identifier generator, a class implementing {@link InMemoryGenerator}. * * @since 6.2 */ - Class type() default IdentifierGenerator.class; + Class type() default InMemoryGenerator.class; /** * The type of identifier generator, the name of either: *