Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 74cd098

Browse files
committed
HHH-19734 Ensure shallow cached entity is not left uninitialized when bytecode enhanced
1 parent bd2087b commit 74cd098

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,10 @@ else if ( isResultInitializer() ) {
11021102
else if ( data.entityHolder.getEntityInitializer() != this ) {
11031103
data.setState( State.INITIALIZED );
11041104
}
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+
}
11051109
}
11061110
else if ( ( entityFromExecutionContext = getEntityFromExecutionContext( data ) ) != null ) {
11071111
// This is the entity to refresh, so don't set the state to initialized
@@ -1214,7 +1218,7 @@ protected Object resolveEntityInstance(EntityInitializerData data) {
12141218
return resolved;
12151219
}
12161220
else {
1217-
if ( rowProcessingState.isQueryCacheHit() && entityDescriptor.useShallowQueryCacheLayout() ) {
1221+
if ( data.shallowCached ) {
12181222
// We must load the entity this way, because the query cache entry contains only the primary key
12191223
data.setState( State.INITIALIZED );
12201224
final SharedSessionContractImplementor session = rowProcessingState.getSession();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /