-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19843 Get persister from session factory if session is not available #11067
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
base: main
Are you sure you want to change the base?
Conversation
hibernate-core/src/main/java/org/hibernate/boot/beanvalidation/BeanValidationEventListener.java
Outdated
Show resolved
Hide resolved
| if ( session != null ) { | ||
| return session.getEntityPersister( entityName, entity ); | ||
| } | ||
| return entityName == null | ||
| ? sessionFactory.getMappingMetamodel().getEntityDescriptor( entity.getClass().getName() ) | ||
| : sessionFactory.getMappingMetamodel().getEntityDescriptor( entityName ) | ||
| .getSubclassEntityPersister( entity, sessionFactory ); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 there is the
hibernate-orm/hibernate-core/src/main/java/org/hibernate/event/spi/AbstractEvent.java
Lines 18 to 19 in 1753cb6
| 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 😖
There was a problem hiding this comment.
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 ?
2901ff0 to
ebed130
Compare
ebed130 to
c91abf1
Compare
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.