@@ -79,7 +79,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
7979 private PersistentClass owner ;
8080 private boolean dynamic ;
8181 private boolean isKey ;
82- private Boolean isGeneric ;
82+ private transient Boolean isGeneric ;
8383 private String roleName ;
8484 private MappedSuperclass mappedSuperclass ;
8585 private Value discriminator ;
@@ -97,7 +97,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
9797 private String [] instantiatorPropertyNames ;
9898
9999 // cache the status of the type
100- private volatile CompositeType type ;
100+ private transient volatile CompositeType type ;
101101
102102 private AggregateColumn aggregateColumn ;
103103 private AggregateColumn parentAggregateColumn ;
@@ -678,11 +678,19 @@ private Generator buildIdentifierGenerator(Dialect dialect, RootClass rootClass)
678678 if ( !value .getCustomIdGeneratorCreator ().isAssigned () ) {
679679 // skip any 'assigned' generators, they would have been
680680 // handled by the StandardGenerationContextLocator
681- generator .addGeneratedValuePlan ( new ValueGenerationPlan (
682- value .createGenerator ( dialect , rootClass , property ),
683- getType ().isMutable () ? injector ( property , getAttributeDeclarer ( rootClass ) ) : null ,
684- i
685- ) );
681+ if ( value .createGenerator ( dialect , rootClass , property )
682+ instanceof BeforeExecutionGenerator beforeExecutionGenerator ) {
683+ generator .addGeneratedValuePlan ( new ValueGenerationPlan (
684+ beforeExecutionGenerator ,
685+ getType ().isMutable ()
686+ ? injector ( property , getAttributeDeclarer ( rootClass ) )
687+ : null ,
688+ i
689+ ) );
690+ }
691+ else {
692+ throw new IdentifierGenerationException ( "Identity generation isn't supported for composite ids" );
693+ }
686694 }
687695 }
688696 }
@@ -755,12 +763,12 @@ public Object locateGenerationContext(SharedSessionContractImplementor session,
755763 }
756764
757765 public static class ValueGenerationPlan implements CompositeNestedGeneratedValueGenerator .GenerationPlan {
758- private final Generator subgenerator ;
766+ private final BeforeExecutionGenerator generator ;
759767 private final Setter injector ;
760768 private final int propertyIndex ;
761769
762- public ValueGenerationPlan (Generator subgenerator , Setter injector , int propertyIndex ) {
763- this .subgenerator = subgenerator ;
770+ public ValueGenerationPlan (BeforeExecutionGenerator generator , Setter injector , int propertyIndex ) {
771+ this .generator = generator ;
764772 this .injector = injector ;
765773 this .propertyIndex = propertyIndex ;
766774 }
@@ -777,9 +785,8 @@ public int getPropertyIndex() {
777785
778786 @ Override
779787 public Object execute (SharedSessionContractImplementor session , Object incomingObject ) {
780- if ( !subgenerator .generatedOnExecution ( incomingObject , session ) ) {
781- return ( (BeforeExecutionGenerator ) subgenerator )
782- .generate ( session , incomingObject , null , INSERT );
788+ if ( !generator .generatedOnExecution ( incomingObject , session ) ) {
789+ return generator .generate ( session , incomingObject , null , INSERT );
783790 }
784791 else {
785792 throw new IdentifierGenerationException ( "Identity generation isn't supported for composite ids" );
@@ -788,15 +795,15 @@ public Object execute(SharedSessionContractImplementor session, Object incomingO
788795
789796 @ Override
790797 public void registerExportables (Database database ) {
791- if ( subgenerator instanceof ExportableProducer ) {
792- ( ( ExportableProducer ) subgenerator ) .registerExportables ( database );
798+ if ( generator instanceof ExportableProducer exportableProducer ) {
799+ exportableProducer .registerExportables ( database );
793800 }
794801 }
795802
796803 @ Override
797804 public void initialize (SqlStringGenerationContext context ) {
798- if ( subgenerator instanceof Configurable ) {
799- ( ( Configurable ) subgenerator ) .initialize ( context );
805+ if ( generator instanceof Configurable configurable ) {
806+ configurable .initialize ( context );
800807 }
801808 }
802809 }
@@ -949,7 +956,8 @@ public void setStructColumnNames(String[] structColumnNames) {
949956
950957 public boolean isGeneric () {
951958 if ( isGeneric == null ) {
952- isGeneric = getComponentClassName () != null && getComponentClass ().getTypeParameters ().length != 0 ;
959+ isGeneric = getComponentClassName () != null
960+ && getComponentClass ().getTypeParameters ().length > 0 ;
953961 }
954962 return isGeneric ;
955963 }
0 commit comments