@@ -1221,7 +1221,7 @@ protected Map<String, SingleIdArrayLoadPlan> generateLazySelectStringsByFetchGro
12211221 // of this class, not its subclasses, but since we
12221222 // are reusing code used for sequential selects, we
12231223 // use the subclass closure
1224- partsToSelect .add ( getAttributeMappings (). get ( getSubclassPropertyIndex ( lazyAttributeDescriptor .getName () ) ) );
1224+ partsToSelect .add ( getAttributeMapping ( getSubclassPropertyIndex ( lazyAttributeDescriptor .getName () ) ) );
12251225 }
12261226
12271227 if ( partsToSelect .isEmpty () ) {
@@ -2915,8 +2915,8 @@ public String generateUpdateString(
29152915 final Update update = createUpdate ().setTableName ( getTableName ( j ) );
29162916
29172917 boolean hasColumns = false ;
2918- for ( int index = 0 ; index < attributeMappings .size () ; index ++ ) {
2919- final AttributeMapping attributeMapping = attributeMappings . get ( index ) ;
2918+ for ( int index = 0 ; index < attributeMappings .length ; index ++ ) {
2919+ final AttributeMapping attributeMapping = attributeMappings [ index ] ;
29202920 if ( isPropertyOfTable ( index , j ) ) {
29212921 // `attributeMapping` is an attribute of the table we are updating
29222922
@@ -3039,8 +3039,8 @@ public String generateInsertString(boolean[] includeProperty, int j) {
30393039
30403040 final Insert insert = createInsert ().setTableName ( getTableName ( j ) );
30413041
3042- for ( int index = 0 ; index < attributeMappings .size () ; index ++ ) {
3043- final AttributeMapping attributeMapping = attributeMappings . get ( index ) ;
3042+ for ( int index = 0 ; index < attributeMappings .length ; index ++ ) {
3043+ final AttributeMapping attributeMapping = attributeMappings [ index ] ;
30443044 if ( isPropertyOfTable ( index , j ) ) {
30453045 // `attributeMapping` is an attribute of the table we are updating
30463046
@@ -5117,10 +5117,10 @@ public void setPropertyValues(Object object, Object[] values) {
51175117 }
51185118 else {
51195119 if ( hasSubclasses () ) {
5120- for ( int i = 0 ; i < attributeMappings .size () ; i ++ ) {
5120+ for ( int i = 0 ; i < attributeMappings .length ; i ++ ) {
51215121 final Object value = values [i ];
51225122 if ( value != UNFETCHED_PROPERTY ) {
5123- final Setter setter = attributeMappings . get ( i ) .getPropertyAccess ().getSetter ();
5123+ final Setter setter = attributeMappings [ i ] .getPropertyAccess ().getSetter ();
51245124 setter .set ( object , value );
51255125 }
51265126 }
@@ -5153,8 +5153,8 @@ public Object[] getPropertyValues(Object object) {
51535153 final BytecodeEnhancementMetadata enhancementMetadata = entityMetamodel .getBytecodeEnhancementMetadata ();
51545154 final LazyAttributesMetadata lazyAttributesMetadata = enhancementMetadata .getLazyAttributesMetadata ();
51555155 final Object [] values = new Object [ getNumberOfAttributeMappings () ];
5156- for ( int i = 0 ; i < attributeMappings .size () ; i ++ ) {
5157- final AttributeMapping attributeMapping = attributeMappings . get ( i ) ;
5156+ for ( int i = 0 ; i < attributeMappings .length ; i ++ ) {
5157+ final AttributeMapping attributeMapping = attributeMappings [ i ] ;
51585158 final AttributeMetadataAccess attributeMetadataAccess = attributeMapping .getAttributeMetadataAccess ();
51595159 if ( ! lazyAttributesMetadata .isLazyAttribute ( attributeMapping .getAttributeName () )
51605160 || enhancementMetadata .isAttributeLoaded ( object , attributeMapping .getAttributeName () ) ) {
@@ -5175,7 +5175,7 @@ public Object[] getPropertyValues(Object object) {
51755175
51765176 @ Override
51775177 public Object getPropertyValue (Object object , int i ) {
5178- return attributeMappings . get ( i ) .getAttributeMetadataAccess ()
5178+ return attributeMappings [ i ] .getAttributeMetadataAccess ()
51795179 .resolveAttributeMetadata ( this )
51805180 .getPropertyAccess ()
51815181 .getGetter ()
@@ -5370,9 +5370,9 @@ public Object[] getPropertyValuesToInsert(
53705370 return accessOptimizer .getPropertyValues ( entity );
53715371 }
53725372
5373- final Object [] result = new Object [this .attributeMappings .size () ];
5374- for ( int i = 0 ; i < this .attributeMappings .size () ; i ++ ) {
5375- result [i ] = this .attributeMappings . get ( i ) .getPropertyAccess ().getGetter ().getForInsert (
5373+ final Object [] result = new Object [this .attributeMappings .length ];
5374+ for ( int i = 0 ; i < this .attributeMappings .length ; i ++ ) {
5375+ result [i ] = this .attributeMappings [ i ] .getPropertyAccess ().getGetter ().getForInsert (
53765376 entity ,
53775377 mergeMap ,
53785378 session
@@ -5668,21 +5668,23 @@ public CacheEntry buildCacheEntry(Object entity, Object[] state, Object version,
56685668 private EntityRowIdMapping rowIdMapping ;
56695669 private EntityDiscriminatorMapping discriminatorMapping ;
56705670
5671- private List < AttributeMapping > attributeMappings ;
5671+ private AttributeMapping [] attributeMappings ;
56725672 protected Map <String , AttributeMapping > declaredAttributeMappings = new LinkedHashMap <>();
56735673 protected List <Fetchable > staticFetchableList ;
56745674
56755675 protected ReflectionOptimizer .AccessOptimizer accessOptimizer ;
56765676
56775677 @ Override
56785678 public void visitAttributeMappings (Consumer <? super AttributeMapping > action ) {
5679- attributeMappings .forEach ( action );
5679+ for ( AttributeMapping attributeMapping : attributeMappings ) {
5680+ action .accept ( attributeMapping );
5681+ }
56805682 }
56815683
56825684 @ Override
56835685 public void forEachAttributeMapping (IndexedConsumer <AttributeMapping > consumer ) {
5684- for ( int i = 0 ; i < attributeMappings .size () ; i ++ ) {
5685- consumer .accept ( i , attributeMappings . get ( i ) );
5686+ for ( int i = 0 ; i < attributeMappings .length ; i ++ ) {
5687+ consumer .accept ( i , attributeMappings [ i ] );
56865688 }
56875689 }
56885690
@@ -5770,7 +5772,7 @@ public void prepareMappingModel(MappingModelCreationProcess creationProcess) {
57705772 if ( hasUpdateGeneratedProperties () ) {
57715773 updateGeneratedValuesProcessor = createGeneratedValuesProcessor ( GenerationTiming .UPDATE );
57725774 }
5773- staticFetchableList = new ArrayList <>( attributeMappings .size () );
5775+ staticFetchableList = new ArrayList <>( attributeMappings .length );
57745776 visitSubTypeAttributeMappings ( attributeMapping -> staticFetchableList .add ( attributeMapping ) );
57755777 return true ;
57765778 }
@@ -5910,13 +5912,11 @@ private NaturalIdMapping generateNaturalIdMapping(MappingModelCreationProcess cr
59105912 // in the collected names. iterate here because it is already alphabetical
59115913
59125914 final List <SingularAttributeMapping > collectedAttrMappings = new ArrayList <>();
5913- this .attributeMappings .forEach (
5914- (attributeMapping ) -> {
5915- if ( attributeNames .contains ( attributeMapping .getAttributeName () ) ) {
5916- collectedAttrMappings .add ( (SingularAttributeMapping ) attributeMapping );
5917- }
5918- }
5919- );
5915+ for ( AttributeMapping attributeMapping : attributeMappings ) {
5916+ if ( attributeNames .contains ( attributeMapping .getAttributeName () ) ) {
5917+ collectedAttrMappings .add ( (SingularAttributeMapping ) attributeMapping );
5918+ }
5919+ }
59205920
59215921 if ( collectedAttrMappings .size () <= 1 ) {
59225922 throw new MappingException ( "Expected multiple natural-id attributes, but found only one: " + getEntityName () );
@@ -6106,12 +6106,12 @@ public int getNumberOfAttributeMappings() {
61066106 // force calculation of `attributeMappings`
61076107 getAttributeMappings ();
61086108 }
6109- return attributeMappings .size () ;
6109+ return attributeMappings .length ;
61106110 }
61116111
61126112 @ Override
61136113 public AttributeMapping getAttributeMapping (int position ) {
6114- return attributeMappings . get ( position ) ;
6114+ return attributeMappings [ position ] ;
61156115 }
61166116
61176117 @ Override
@@ -6134,6 +6134,14 @@ public EntityMappingType getSuperMappingType() {
61346134 return superMappingType ;
61356135 }
61366136
6137+ @ Override
6138+ public Collection <EntityMappingType > getSubMappingTypes () {
6139+ if ( subclassMappingTypes == null ) {
6140+ return Collections .emptyList ();
6141+ }
6142+ return subclassMappingTypes .values ();
6143+ }
6144+
61376145 @ Override
61386146 public boolean isTypeOrSuperType (EntityMappingType targetType ) {
61396147 if ( targetType == null ) {
@@ -6534,18 +6542,18 @@ public EntityDiscriminatorMapping getDiscriminatorMapping() {
65346542 @ Override
65356543 public List <AttributeMapping > getAttributeMappings () {
65366544 if ( attributeMappings == null ) {
6537- attributeMappings = new ArrayList <>();
6545+ ArrayList < AttributeMapping > attributeMappings = new ArrayList <>();
65386546
65396547 if ( superMappingType != null ) {
65406548 superMappingType .visitAttributeMappings ( attributeMappings ::add );
65416549 }
65426550
65436551 attributeMappings .addAll ( declaredAttributeMappings .values () );
6544-
6552+ this . attributeMappings = attributeMappings . toArray ( new AttributeMapping [ 0 ]);
65456553 // subclasses? it depends on the usage
65466554 }
65476555
6548- return attributeMappings ;
6556+ return Arrays . asList ( attributeMappings ) ;
65496557 }
65506558
65516559 @ Override
@@ -6769,7 +6777,9 @@ public void visitFetchables(
67696777 visitSubTypeAttributeMappings ( fetchableConsumer );
67706778 }
67716779 else {
6772- attributeMappings .forEach ( fetchableConsumer );
6780+ for ( AttributeMapping attributeMapping : attributeMappings ) {
6781+ fetchableConsumer .accept ( attributeMapping );
6782+ }
67736783 }
67746784 }
67756785
@@ -6785,9 +6795,9 @@ public void visitFetchables(IndexedConsumer<Fetchable> fetchableConsumer, Entity
67856795 return ;
67866796 }
67876797
6788- final int size = attributeMappings .size () ;
6798+ final int size = attributeMappings .length ;
67896799 for ( int i = 0 ; i < size ; i ++ ) {
6790- fetchableConsumer .accept ( i , attributeMappings . get ( i ) );
6800+ fetchableConsumer .accept ( i , attributeMappings [ i ] );
67916801 }
67926802 if ( treatTargetType .isTypeOrSuperType ( this ) ) {
67936803 if ( subclassMappingTypes != null ) {
@@ -6810,7 +6820,9 @@ protected List<Fetchable> getStaticFetchableList() {
68106820 public void visitAttributeMappings (
68116821 Consumer <? super AttributeMapping > action ,
68126822 EntityMappingType targetType ) {
6813- attributeMappings .forEach ( action );
6823+ for ( AttributeMapping attributeMapping : attributeMappings ) {
6824+ action .accept ( attributeMapping );
6825+ }
68146826 }
68156827
68166828 @ Override
@@ -6823,9 +6835,8 @@ public void visitSuperTypeAttributeMappings(Consumer<? super AttributeMapping> a
68236835 @ Override
68246836 public int forEachSelectable (int offset , SelectableConsumer selectableConsumer ) {
68256837 int span = 0 ;
6826- final List <AttributeMapping > mappings = getAttributeMappings ();
6827- for ( int i = 0 ; i < mappings .size (); i ++ ) {
6828- span += mappings .get ( i ).forEachSelectable ( span + offset , selectableConsumer );
6838+ for ( AttributeMapping attributeMapping : attributeMappings ) {
6839+ span += attributeMapping .forEachSelectable ( span + offset , selectableConsumer );
68296840 }
68306841 return span ;
68316842 }
0 commit comments