Skip to content

Commit 2e19be1

Browse files
committed
HHH-Allow Hibernate Reactive to register a org.hibernate.loader.ast.spi.AfterLoadAction
1 parent 4170c9e commit 2e19be1

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ private void processLoadedEntityHolder(
489489
getSession()
490490
);
491491
}
492-
( (EntityHolderImpl) holder ).entityInitializer = null;
492+
holder.resetEntityInitialier();
493493
}
494494
}
495495

@@ -2297,6 +2297,11 @@ public boolean isDetached() {
22972297
return state == EntityHolderState.DETACHED;
22982298
}
22992299

2300+
@Override
2301+
public void resetEntityInitialier(){
2302+
entityInitializer = null;
2303+
}
2304+
23002305
public EntityHolderImpl withEntity(EntityKey entityKey, EntityPersister descriptor, Object entity) {
23012306
return withData( entityKey, descriptor, entity, null );
23022307
}

hibernate-core/src/main/java/org/hibernate/engine/spi/EntityHolder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,12 @@ public interface EntityHolder {
7070
* Whether the entity is detached.
7171
*/
7272
boolean isDetached();
73+
74+
75+
/**
76+
* For Hibernate Reactive
77+
*
78+
* Set the EntityInitializer to null
79+
*/
80+
void resetEntityInitialier();
7381
}

hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DeferredResultSetAccess.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,7 @@ public DeferredResultSetAccess(
112112
lockOptionsToUse.setTimeOut( lockOptions.getTimeOut() );
113113
lockOptionsToUse.setLockScope( lockOptions.getLockScope() );
114114

115-
executionContext.getCallback().registerAfterLoadAction( (entity, persister, session) ->
116-
session.asSessionImplementor().lock(
117-
persister.getEntityName(),
118-
entity,
119-
lockOptionsToUse
120-
)
121-
);
115+
registerAfterLoadAction( executionContext, lockOptionsToUse );
122116
}
123117
}
124118
else {
@@ -136,6 +130,19 @@ public DeferredResultSetAccess(
136130
}
137131
}
138132

133+
/**
134+
* For Hibernate Reactive
135+
*/
136+
protected void registerAfterLoadAction(ExecutionContext executionContext, LockOptions lockOptionsToUse) {
137+
executionContext.getCallback().registerAfterLoadAction( (entity, persister, session) ->
138+
session.asSessionImplementor().lock(
139+
persister.getEntityName(),
140+
entity,
141+
lockOptionsToUse
142+
)
143+
);
144+
}
145+
139146
private static boolean useFollowOnLocking(
140147
JdbcLockStrategy jdbcLockStrategy,
141148
String sql,

hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ else if ( getSession() instanceof EventSource ) {
145145
}
146146
}
147147

148-
149-
private void finishLoadingCollections() {
148+
/**
149+
* For Hibernate Reactive
150+
*/
151+
public void finishLoadingCollections() {
150152
if ( loadingCollectionMap != null ) {
151153
for ( LoadingCollectionEntry loadingCollectionEntry : loadingCollectionMap.values() ) {
152154
loadingCollectionEntry.finishLoading( getExecutionContext() );

0 commit comments

Comments
 (0)