Skip to content
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

Reactive find with lock in Quarkus with reactive hibernate #2117

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dreab8
Copy link
Member

@dreab8 dreab8 commented Feb 13, 2025

Fix #1905

rowProcessingState.finishRowProcessing( true );
rowReader.finishUp( rowProcessingState );
jdbcValuesSourceProcessingState.finishUp( false );
return result;
session.getPersistenceContext();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove session.getPersistenceContext()

Copy link
Member

@DavideD DavideD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, thanks a lot.

I might just need some clarifications on a couple of changes.

final EventListenerGroup<PostLoadEventListener> listenerGroup =
getSession().getFactory().getEventListenerGroups().eventListenerGroup_POST_LOAD;
final PostLoadEvent postLoadEvent = processingState.getPostLoadEvent();
return loop(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Hibernate ORM the code looks like this:

if ( processingState.getLoadingEntityHolders() != null ) {
	final EventListenerGroup<PostLoadEventListener> listenerGroup =
			getSession().getFactory().getEventListenerGroups().eventListenerGroup_POST_LOAD;
	final PostLoadEvent postLoadEvent = processingState.getPostLoadEvent();
	for ( final EntityHolder holder : processingState.getLoadingEntityHolders() ) {
		processLoadedEntityHolder( holder, listenerGroup, postLoadEvent, callback, holderConsumer );
	}
	processingState.getLoadingEntityHolders().clear();
}
if ( processingState.getReloadedEntityHolders() != null ) {
	for ( final EntityHolder holder : processingState.getReloadedEntityHolders() ) {
		processLoadedEntityHolder( holder, null, null, callback, holderConsumer );
	}
	processingState.getReloadedEntityHolders().clear();
}

There is not a return at the end of the first if-then block. It means that the two conditions getLoadingEntityHolders() != null and processingState.getReloadedEntityHolders() != null could both be true and both blocks should be evaluated.

Did you add a return loop( ... because you understand what's going on or is this an error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably it can be avoided

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

/**
* Reactive equivalent of {@link org.hibernate.sql.exec.internal.CallbackImpl}
*/
public class ReactiveCallbackImpl implements Callback {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove some code here if

  • ReactiveAfterLoadAction extends AfterLoadAction
  • ReactiveCallBackImpl extends CallbackImpl
  • We add a method getAfterLoadActions() in CallBackImpl

But, we can do it in a separate PR, otherwise we will have to wait for the next ORM release.

callback,
holderConsumer
))
.thenAccept( v -> processingState.getLoadingEntityHolders().clear() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it should be using getReloadedEntityHolders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reactive find with lock in Quarkus with reactive hibernate - Issue reproduced
2 participants