Skip to content

HHH-19083 Allow Hibernate Reactive to register a org.hibernate.loader.ast.spi.AfterLoadAction #9677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ private void processLoadedEntityHolder(
getSession()
);
}
( (EntityHolderImpl) holder ).entityInitializer = null;
holder.resetEntityInitialier();
}
}

Expand Down Expand Up @@ -2297,6 +2297,11 @@ public boolean isDetached() {
return state == EntityHolderState.DETACHED;
}

@Override
public void resetEntityInitialier(){
entityInitializer = null;
}

public EntityHolderImpl withEntity(EntityKey entityKey, EntityPersister descriptor, Object entity) {
return withData( entityKey, descriptor, entity, null );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ public interface EntityHolder {
* Whether the entity is detached.
*/
boolean isDetached();


/**
* For Hibernate Reactive
*
* Set the EntityInitializer to null
*/
void resetEntityInitialier();
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,7 @@ public DeferredResultSetAccess(
lockOptionsToUse.setTimeOut( lockOptions.getTimeOut() );
lockOptionsToUse.setLockScope( lockOptions.getLockScope() );

executionContext.getCallback().registerAfterLoadAction( (entity, persister, session) ->
session.asSessionImplementor().lock(
persister.getEntityName(),
entity,
lockOptionsToUse
)
);
registerAfterLoadAction( executionContext, lockOptionsToUse );
}
}
else {
Expand All @@ -136,6 +130,19 @@ public DeferredResultSetAccess(
}
}

/**
* For Hibernate Reactive
*/
protected void registerAfterLoadAction(ExecutionContext executionContext, LockOptions lockOptionsToUse) {
executionContext.getCallback().registerAfterLoadAction( (entity, persister, session) ->
session.asSessionImplementor().lock(
persister.getEntityName(),
entity,
lockOptionsToUse
)
);
}

private static boolean useFollowOnLocking(
JdbcLockStrategy jdbcLockStrategy,
String sql,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ else if ( getSession() instanceof EventSource ) {
}
}


private void finishLoadingCollections() {
/**
* For Hibernate Reactive
*/
public void finishLoadingCollections() {
if ( loadingCollectionMap != null ) {
for ( LoadingCollectionEntry loadingCollectionEntry : loadingCollectionMap.values() ) {
loadingCollectionEntry.finishLoading( getExecutionContext() );
Expand Down
Loading