@@ -79,7 +79,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
79
79
private PersistentClass owner ;
80
80
private boolean dynamic ;
81
81
private boolean isKey ;
82
- private Boolean isGeneric ;
82
+ private transient Boolean isGeneric ;
83
83
private String roleName ;
84
84
private MappedSuperclass mappedSuperclass ;
85
85
private Value discriminator ;
@@ -97,7 +97,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
97
97
private String [] instantiatorPropertyNames ;
98
98
99
99
// cache the status of the type
100
- private volatile CompositeType type ;
100
+ private transient volatile CompositeType type ;
101
101
102
102
private AggregateColumn aggregateColumn ;
103
103
private AggregateColumn parentAggregateColumn ;
@@ -678,11 +678,19 @@ private Generator buildIdentifierGenerator(Dialect dialect, RootClass rootClass)
678
678
if ( !value .getCustomIdGeneratorCreator ().isAssigned () ) {
679
679
// skip any 'assigned' generators, they would have been
680
680
// 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
+ }
686
694
}
687
695
}
688
696
}
@@ -755,12 +763,12 @@ public Object locateGenerationContext(SharedSessionContractImplementor session,
755
763
}
756
764
757
765
public static class ValueGenerationPlan implements CompositeNestedGeneratedValueGenerator .GenerationPlan {
758
- private final Generator subgenerator ;
766
+ private final BeforeExecutionGenerator generator ;
759
767
private final Setter injector ;
760
768
private final int propertyIndex ;
761
769
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 ;
764
772
this .injector = injector ;
765
773
this .propertyIndex = propertyIndex ;
766
774
}
@@ -777,9 +785,8 @@ public int getPropertyIndex() {
777
785
778
786
@ Override
779
787
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 );
783
790
}
784
791
else {
785
792
throw new IdentifierGenerationException ( "Identity generation isn't supported for composite ids" );
@@ -788,15 +795,15 @@ public Object execute(SharedSessionContractImplementor session, Object incomingO
788
795
789
796
@ Override
790
797
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 );
793
800
}
794
801
}
795
802
796
803
@ Override
797
804
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 );
800
807
}
801
808
}
802
809
}
@@ -949,7 +956,8 @@ public void setStructColumnNames(String[] structColumnNames) {
949
956
950
957
public boolean isGeneric () {
951
958
if ( isGeneric == null ) {
952
- isGeneric = getComponentClassName () != null && getComponentClass ().getTypeParameters ().length != 0 ;
959
+ isGeneric = getComponentClassName () != null
960
+ && getComponentClass ().getTypeParameters ().length > 0 ;
953
961
}
954
962
return isGeneric ;
955
963
}
0 commit comments