Skip to content

Conversation

@marko-bekhta
Copy link
Member

https://hibernate.atlassian.net/browse/HHH-19843


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


@marko-bekhta marko-bekhta requested a review from mbellade October 6, 2025 15:23
Comment on lines +123 to +128
if ( session != null ) {
return session.getEntityPersister( entityName, entity );
}
return entityName == null
? sessionFactory.getMappingMetamodel().getEntityDescriptor( entity.getClass().getName() )
: sessionFactory.getMappingMetamodel().getEntityDescriptor( entityName )
.getSubclassEntityPersister( entity, sessionFactory );
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a fine workaround, but I wonder if we could rather make org.hibernate.event.spi.AbstractSessionEvent take a org.hibernate.engine.spi.SharedSessionContractImplementor instead of org.hibernate.event.spi.EventSource, deprecating the old signature (and delegating to the new one since EventSource extends SharedSessionContractImplementor.

Since stateless session fire this events too now, it would make more sense to be able to retrieve them in AbstractSessionEvent#getSession (which, as the name implies, could not only return EventSources). Perhaps let's hear what @gavinking thinks.

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 there is the

public abstract class AbstractEvent implements Serializable {
protected final SharedSessionContractImplementor source;

but it's a different hierarchy of events, and these collection ones don't get the same source 😖

Copy link
Member Author

Choose a reason for hiding this comment

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

hey 👋🏻 🙂

since this is causing issues using Jakarta Data in 7.1, I'd suggest we merge this patch as is and backport it to 7.1
and then plan to rework the events in 7.3, or 8.0 🙂 depending on how much "rework" it would be ?

@marko-bekhta marko-bekhta force-pushed the fix/HHH-19843-Bean-Validation-may-fail-on-operations-with-stateless-session branch from 2901ff0 to ebed130 Compare October 6, 2025 16:27
@marko-bekhta marko-bekhta force-pushed the fix/HHH-19843-Bean-Validation-may-fail-on-operations-with-stateless-session branch from ebed130 to c91abf1 Compare November 21, 2025 08:25
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.

2 participants