@@ -1118,6 +1118,10 @@ else if ( isResultInitializer() ) {
1118
1118
else if ( data .entityHolder .getEntityInitializer () != this ) {
1119
1119
data .setState ( State .INITIALIZED );
1120
1120
}
1121
+ else if ( data .shallowCached ) {
1122
+ // For shallow cached entities, only the id is available, so ensure we load the data immediately
1123
+ data .setInstance ( data .entityInstanceForNotify = resolveEntityInstance ( data ) );
1124
+ }
1121
1125
}
1122
1126
else if ( ( entityFromExecutionContext = getEntityFromExecutionContext ( data ) ) != null ) {
1123
1127
// This is the entity to refresh, so don't set the state to initialized
@@ -1231,7 +1235,7 @@ protected Object resolveEntityInstance(EntityInitializerData data) {
1231
1235
return resolved ;
1232
1236
}
1233
1237
else {
1234
- if ( rowProcessingState . isQueryCacheHit () && entityDescriptor . useShallowQueryCacheLayout () ) {
1238
+ if ( data . shallowCached ) {
1235
1239
// We must load the entity this way, because the query cache entry contains only the primary key
1236
1240
data .setState ( State .INITIALIZED );
1237
1241
final SharedSessionContractImplementor session = rowProcessingState .getSession ();
0 commit comments