@@ -1102,6 +1102,10 @@ else if ( isResultInitializer() ) {
1102
1102
else if ( data .entityHolder .getEntityInitializer () != this ) {
1103
1103
data .setState ( State .INITIALIZED );
1104
1104
}
1105
+ else if ( data .shallowCached ) {
1106
+ // For shallow cached entities, only the id is available, so ensure we load the data immediately
1107
+ data .setInstance ( data .entityInstanceForNotify = resolveEntityInstance ( data ) );
1108
+ }
1105
1109
}
1106
1110
else if ( ( entityFromExecutionContext = getEntityFromExecutionContext ( data ) ) != null ) {
1107
1111
// This is the entity to refresh, so don't set the state to initialized
@@ -1214,7 +1218,7 @@ protected Object resolveEntityInstance(EntityInitializerData data) {
1214
1218
return resolved ;
1215
1219
}
1216
1220
else {
1217
- if ( rowProcessingState . isQueryCacheHit () && entityDescriptor . useShallowQueryCacheLayout () ) {
1221
+ if ( data . shallowCached ) {
1218
1222
// We must load the entity this way, because the query cache entry contains only the primary key
1219
1223
data .setState ( State .INITIALIZED );
1220
1224
final SharedSessionContractImplementor session = rowProcessingState .getSession ();
0 commit comments