@@ -1273,45 +1273,36 @@ default Object initLazyProperty(String fieldName, Object entity,
1273
1273
List <LazyAttributeDescriptor > fetchGroupAttributeDescriptors ,
1274
1274
Set <String > initializedLazyAttributeNames ,
1275
1275
ResultSet resultSet ) {
1276
+ // Load all the lazy properties that are in the same fetch group
1277
+ Object result = null ;
1276
1278
for ( LazyAttributeDescriptor fetchGroupAttributeDescriptor : fetchGroupAttributeDescriptors ) {
1277
1279
1278
1280
if ( initializedLazyAttributeNames .contains ( fetchGroupAttributeDescriptor .getName () ) ) {
1281
+ // Already initialized
1282
+ if ( fetchGroupAttributeDescriptor .getName ().equals ( fieldName ) ) {
1283
+ result = entry .getLoadedValue ( fetchGroupAttributeDescriptor .getName () );
1284
+ }
1279
1285
continue ;
1280
1286
}
1281
1287
1282
- final Object selectedValue ;
1283
1288
try {
1284
- selectedValue = fetchGroupAttributeDescriptor .getType ().nullSafeGet (
1285
- resultSet ,
1286
- getLazyPropertyColumnAliases ()[ fetchGroupAttributeDescriptor .getLazyIndex () ],
1287
- session ,
1288
- entity
1289
- );
1289
+ String [] columnAlias = getLazyPropertyColumnAliases ()[fetchGroupAttributeDescriptor .getLazyIndex ()];
1290
+ final Object selectedValue = fetchGroupAttributeDescriptor .getType ()
1291
+ .nullSafeGet ( resultSet , columnAlias , session , entity );
1292
+ final boolean set = initializeLazyProperty ( fieldName , entity , session , entry , fetchGroupAttributeDescriptor .getLazyIndex (), selectedValue );
1293
+ if ( set ) {
1294
+ result = selectedValue ;
1295
+ interceptor .attributeInitialized ( fetchGroupAttributeDescriptor .getName () );
1296
+ }
1290
1297
}
1291
1298
catch (SQLException sqle ) {
1292
1299
//can't occur
1293
1300
throw new JDBCException ("error initializing lazy property" , sqle );
1294
1301
}
1295
-
1296
- final boolean set = initializeLazyProperty (
1297
- fieldName ,
1298
- entity ,
1299
- session ,
1300
- entry ,
1301
- fetchGroupAttributeDescriptor .getLazyIndex (),
1302
- selectedValue
1303
- );
1304
-
1305
- if ( set ) {
1306
- interceptor .attributeInitialized ( fetchGroupAttributeDescriptor .getName () );
1307
- }
1308
-
1309
- log .trace ( "Done initializing lazy properties" );
1310
-
1311
- return selectedValue ;
1312
1302
}
1313
1303
1314
- return null ;
1304
+ log .trace ( "Done initializing lazy properties" );
1305
+ return result ;
1315
1306
}
1316
1307
1317
1308
default CompletionStage <Object > reactiveInitializeEnhancedEntityUsedAsProxy (
0 commit comments