@@ -1273,45 +1273,36 @@ default Object initLazyProperty(String fieldName, Object entity,
12731273 List <LazyAttributeDescriptor > fetchGroupAttributeDescriptors ,
12741274 Set <String > initializedLazyAttributeNames ,
12751275 ResultSet resultSet ) {
1276+ // Load all the lazy properties that are in the same fetch group
1277+ Object result = null ;
12761278 for ( LazyAttributeDescriptor fetchGroupAttributeDescriptor : fetchGroupAttributeDescriptors ) {
12771279
12781280 if ( initializedLazyAttributeNames .contains ( fetchGroupAttributeDescriptor .getName () ) ) {
1281+ // Already initialized
1282+ if ( fetchGroupAttributeDescriptor .getName ().equals ( fieldName ) ) {
1283+ result = entry .getLoadedValue ( fetchGroupAttributeDescriptor .getName () );
1284+ }
12791285 continue ;
12801286 }
12811287
1282- final Object selectedValue ;
12831288 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+ }
12901297 }
12911298 catch (SQLException sqle ) {
12921299 //can't occur
12931300 throw new JDBCException ("error initializing lazy property" , sqle );
12941301 }
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 ;
13121302 }
13131303
1314- return null ;
1304+ log .trace ( "Done initializing lazy properties" );
1305+ return result ;
13151306 }
13161307
13171308 default CompletionStage <Object > reactiveInitializeEnhancedEntityUsedAsProxy (
0 commit comments