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

HHH-19205 Do not recreate the validator on each BeanValidationEventListener#validate call #9806

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marko-bekhta
Copy link
Member

@marko-bekhta marko-bekhta commented Feb 26, 2025

Hey @gavinking , @beikov

Since you've been talking about the validator in the other PR 😄 it got me interested.
The fact that we recreate the validator on each validate call feels a bit redundant, so I've started looking into it. And this PR is where I got so far.

It would be nice if we wouldn't need to have that traversableResolver.addPersisterIfNecessary( persister, sessionFactory ); I've added. But to get rid of it, we need to have access to the built SF (not the one being built that we can get our hands on right now from the integrator). Would it make sense to add some Integrator#postintegrate(Sf sf... ) method that is called at the very end of the SF constructor, then eagerly build the association map?
Or am I missing something here 😄


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.


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

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Feb 26, 2025

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

Copy link
Member

@beikov beikov left a comment

Choose a reason for hiding this comment

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

LGTM

@gavinking
Copy link
Member

Would it make sense to add some Integrator#postintegrate(Sf sf... ) method that is called at the very end of the SF constructor

Sounds reasonable. Or you could register a, um, what's it called? SessionFactoryObserver?

@marko-bekhta marko-bekhta force-pushed the fix/traversable-resolver-single-validator branch from 7ae0202 to b72591b Compare February 26, 2025 16:23
@marko-bekhta marko-bekhta changed the title Do not recreate the validator on each BeanValidationEventListener#validate call HHH-19205 Do not recreate the validator on each BeanValidationEventListener#validate call Feb 26, 2025
@marko-bekhta
Copy link
Member Author

SessionFactoryObserver seems to work out nicely 😃,
with it, I also removed the concurrent map, as we are now prefilled with all the entities.

@marko-bekhta
Copy link
Member Author

btw ... since it's in the org.hibernate.boot.beanvalidation (public package?), do you want me to mention something in the migration guide or somewhere?

@marko-bekhta marko-bekhta marked this pull request as ready for review February 26, 2025 16:31
@gavinking
Copy link
Member

btw ... since it's in the org.hibernate.boot.beanvalidation (public package?), do you want me to mention something in the migration guide or somewhere?

Nooooooooo, these are definitely implementation details.

The migration guide would be completely useless if it mentioned every single implementation change. Ideally, it should draw people's attention to things they actually need to pay attention to.

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.

3 participants