4848
4949import org .checkerframework .checker .nullness .qual .Nullable ;
5050
51+ import static org .hibernate .internal .util .collections .CollectionHelper .arrayList ;
52+
5153/**
5254 * Base implementation for composite identifier mappings
5355 *
@@ -66,7 +68,9 @@ public AbstractCompositeIdentifierMapping(
6668 EntityMappingType entityMapping ,
6769 String tableExpression ,
6870 MappingModelCreationProcess creationProcess ) {
69- this .navigableRole = entityMapping .getNavigableRole ().appendContainer ( EntityIdentifierMapping .ID_ROLE_NAME );
71+ this .navigableRole =
72+ entityMapping .getNavigableRole ()
73+ .appendContainer ( ID_ROLE_NAME );
7074 this .entityMapping = entityMapping ;
7175 this .tableExpression = tableExpression ;
7276 this .sessionFactory = creationProcess .getCreationContext ().getSessionFactory ();
@@ -135,8 +139,8 @@ public TableGroupJoin createTableGroupJoin(
135139 boolean fetched ,
136140 boolean addsPredicate ,
137141 SqlAstCreationState creationState ) {
138- final SqlAstJoinType joinType = determineSqlJoinType ( lhs , requestedJoinType , fetched );
139- final TableGroup tableGroup = createRootTableGroupJoin (
142+ final var joinType = determineSqlJoinType ( lhs , requestedJoinType , fetched );
143+ final var tableGroup = createRootTableGroupJoin (
140144 navigablePath ,
141145 lhs ,
142146 explicitSourceAlias ,
@@ -146,7 +150,6 @@ public TableGroupJoin createTableGroupJoin(
146150 null ,
147151 creationState
148152 );
149-
150153 return new TableGroupJoin ( navigablePath , joinType , tableGroup , null );
151154 }
152155
@@ -184,26 +187,24 @@ public <X, Y> int forEachJdbcValue(
184187 JdbcValuesBiConsumer <X , Y > valuesConsumer ,
185188 SharedSessionContractImplementor session ) {
186189 int span = 0 ;
187- final EmbeddableMappingType embeddableTypeDescriptor = getEmbeddableTypeDescriptor ();
190+ final var embeddableTypeDescriptor = getEmbeddableTypeDescriptor ();
188191 final int size = embeddableTypeDescriptor .getNumberOfAttributeMappings ();
189192 if ( value == null ) {
190193 for ( int i = 0 ; i < size ; i ++ ) {
191- final AttributeMapping attributeMapping = embeddableTypeDescriptor .getAttributeMapping ( i );
194+ final var attributeMapping = embeddableTypeDescriptor .getAttributeMapping ( i );
192195 span += attributeMapping .forEachJdbcValue ( null , span + offset , x , y , valuesConsumer , session );
193196 }
194197 }
195198 else {
196199 for ( int i = 0 ; i < size ; i ++ ) {
197- final AttributeMapping attributeMapping = embeddableTypeDescriptor .getAttributeMapping ( i );
198- final Object o = embeddableTypeDescriptor .getValue ( value , i );
200+ final var attributeMapping = embeddableTypeDescriptor .getAttributeMapping ( i );
201+ final Object object = embeddableTypeDescriptor .getValue ( value , i );
199202 if ( attributeMapping instanceof ToOneAttributeMapping toOneAttributeMapping ) {
200- final ForeignKeyDescriptor fkDescriptor = toOneAttributeMapping .getForeignKeyDescriptor ();
201- final Object identifier = fkDescriptor .getAssociationKeyFromSide (
202- o ,
203- toOneAttributeMapping .getSideNature ().inverse (),
204- session
205- );
206- span += fkDescriptor .forEachJdbcValue (
203+ final var foreignKeyDescriptor = toOneAttributeMapping .getForeignKeyDescriptor ();
204+ final var inverse = toOneAttributeMapping .getSideNature ().inverse ();
205+ final Object identifier =
206+ foreignKeyDescriptor .getAssociationKeyFromSide ( object , inverse , session );
207+ span += foreignKeyDescriptor .forEachJdbcValue (
207208 identifier ,
208209 span + offset ,
209210 x ,
@@ -213,7 +214,7 @@ public <X, Y> int forEachJdbcValue(
213214 );
214215 }
215216 else {
216- span += attributeMapping .forEachJdbcValue ( o , span + offset , x , y , valuesConsumer , session );
217+ span += attributeMapping .forEachJdbcValue ( object , span + offset , x , y , valuesConsumer , session );
217218 }
218219 }
219220 }
@@ -226,22 +227,22 @@ public SqlTuple toSqlExpression(
226227 Clause clause ,
227228 SqmToSqlAstConverter walker ,
228229 SqlAstCreationState sqlAstCreationState ) {
229- final SelectableMappings selectableMappings = getEmbeddableTypeDescriptor ();
230- final List <ColumnReference > columnReferences = CollectionHelper .arrayList ( selectableMappings .getJdbcTypeCount () );
231- final NavigablePath navigablePath = tableGroup .getNavigablePath ().append ( getNavigableRole ().getNavigableName () );
232- final TableReference defaultTableReference = tableGroup .resolveTableReference ( navigablePath , getContainingTableExpression () );
230+ final List <ColumnReference > columnReferences = arrayList ( getEmbeddableTypeDescriptor ().getJdbcTypeCount () );
231+ final var navigablePath = tableGroup .getNavigablePath ().append ( getNavigableRole ().getNavigableName () );
232+ final var defaultTableReference = tableGroup .resolveTableReference ( navigablePath , getContainingTableExpression () );
233233 getEmbeddableTypeDescriptor ().forEachSelectable (
234234 (columnIndex , selection ) -> {
235- final TableReference tableReference = getContainingTableExpression ().equals ( selection .getContainingTableExpression () )
236- ? defaultTableReference
237- : tableGroup .resolveTableReference ( navigablePath , selection .getContainingTableExpression () );
238- final Expression columnReference = sqlAstCreationState .getSqlExpressionResolver ()
239- .resolveSqlExpression ( tableReference , selection );
240-
235+ final String containingTableExpression = selection .getContainingTableExpression ();
236+ final var tableReference =
237+ getContainingTableExpression ().equals ( containingTableExpression )
238+ ? defaultTableReference
239+ : tableGroup .resolveTableReference ( navigablePath , containingTableExpression );
240+ final var columnReference =
241+ sqlAstCreationState .getSqlExpressionResolver ()
242+ .resolveSqlExpression ( tableReference , selection );
241243 columnReferences .add ( (ColumnReference ) columnReference );
242244 }
243245 );
244-
245246 return new SqlTuple ( columnReferences , this );
246247 }
247248
0 commit comments