@@ -81,7 +81,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
8181 private PersistentClass owner ;
8282 private boolean dynamic ;
8383 private boolean isKey ;
84- private Boolean isGeneric ;
84+ private transient Boolean isGeneric ;
8585 private String roleName ;
8686 private MappedSuperclass mappedSuperclass ;
8787 private Value discriminator ;
@@ -99,7 +99,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
9999 private String [] instantiatorPropertyNames ;
100100
101101 // cache the status of the type
102- private volatile CompositeType type ;
102+ private transient volatile CompositeType type ;
103103
104104 private AggregateColumn aggregateColumn ;
105105 private AggregateColumn parentAggregateColumn ;
@@ -680,11 +680,19 @@ private Generator buildIdentifierGenerator(Dialect dialect, RootClass rootClass)
680680 if ( !value .getCustomIdGeneratorCreator ().isAssigned () ) {
681681 // skip any 'assigned' generators, they would have been
682682 // handled by the StandardGenerationContextLocator
683- generator .addGeneratedValuePlan ( new ValueGenerationPlan (
684- value .createGenerator ( dialect , rootClass , property ),
685- getType ().isMutable () ? injector ( property , getAttributeDeclarer ( rootClass ) ) : null ,
686- i
687- ) );
683+ if ( value .createGenerator ( dialect , rootClass , property )
684+ instanceof BeforeExecutionGenerator beforeExecutionGenerator ) {
685+ generator .addGeneratedValuePlan ( new ValueGenerationPlan (
686+ beforeExecutionGenerator ,
687+ getType ().isMutable ()
688+ ? injector ( property , getAttributeDeclarer ( rootClass ) )
689+ : null ,
690+ i
691+ ) );
692+ }
693+ else {
694+ throw new IdentifierGenerationException ( "Identity generation isn't supported for composite ids" );
695+ }
688696 }
689697 }
690698 }
@@ -757,12 +765,12 @@ public Object locateGenerationContext(SharedSessionContractImplementor session,
757765 }
758766
759767 public static class ValueGenerationPlan implements CompositeNestedGeneratedValueGenerator .GenerationPlan {
760- private final Generator subgenerator ;
768+ private final BeforeExecutionGenerator generator ;
761769 private final Setter injector ;
762770 private final int propertyIndex ;
763771
764- public ValueGenerationPlan (Generator subgenerator , Setter injector , int propertyIndex ) {
765- this .subgenerator = subgenerator ;
772+ public ValueGenerationPlan (BeforeExecutionGenerator generator , Setter injector , int propertyIndex ) {
773+ this .generator = generator ;
766774 this .injector = injector ;
767775 this .propertyIndex = propertyIndex ;
768776 }
@@ -779,9 +787,8 @@ public int getPropertyIndex() {
779787
780788 @ Override
781789 public Object execute (SharedSessionContractImplementor session , Object incomingObject ) {
782- if ( !subgenerator .generatedOnExecution ( incomingObject , session ) ) {
783- return ( (BeforeExecutionGenerator ) subgenerator )
784- .generate ( session , incomingObject , null , INSERT );
790+ if ( !generator .generatedOnExecution ( incomingObject , session ) ) {
791+ return generator .generate ( session , incomingObject , null , INSERT );
785792 }
786793 else {
787794 throw new IdentifierGenerationException ( "Identity generation isn't supported for composite ids" );
@@ -790,15 +797,15 @@ public Object execute(SharedSessionContractImplementor session, Object incomingO
790797
791798 @ Override
792799 public void registerExportables (Database database ) {
793- if ( subgenerator instanceof ExportableProducer ) {
794- ( ( ExportableProducer ) subgenerator ) .registerExportables ( database );
800+ if ( generator instanceof ExportableProducer exportableProducer ) {
801+ exportableProducer .registerExportables ( database );
795802 }
796803 }
797804
798805 @ Override
799806 public void initialize (SqlStringGenerationContext context ) {
800- if ( subgenerator instanceof Configurable ) {
801- ( ( Configurable ) subgenerator ) .initialize ( context );
807+ if ( generator instanceof Configurable configurable ) {
808+ configurable .initialize ( context );
802809 }
803810 }
804811 }
@@ -951,7 +958,8 @@ public void setStructColumnNames(String[] structColumnNames) {
951958
952959 public boolean isGeneric () {
953960 if ( isGeneric == null ) {
954- isGeneric = getComponentClassName () != null && getComponentClass ().getTypeParameters ().length != 0 ;
961+ isGeneric = getComponentClassName () != null
962+ && getComponentClass ().getTypeParameters ().length > 0 ;
955963 }
956964 return isGeneric ;
957965 }
0 commit comments