-
Couldn't load subscription status.
- Fork 41.6k
Allow EntityManagerFactoryBuilder to also add PersistenceUnitPostProcessor instances #47802
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?
Allow EntityManagerFactoryBuilder to also add PersistenceUnitPostProcessor instances #47802
Conversation
0a533b5 to
702c81a
Compare
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.
Thanks for the PR. I've left a couple comments for your consideration.
| ObjectProvider<PersistenceUnitManager> persistenceUnitManager, | ||
| ObjectProvider<EntityManagerFactoryBuilderCustomizer> customizers) { | ||
| ObjectProvider<EntityManagerFactoryBuilderCustomizer> customizers, | ||
| PersistenceUnitPostProcessor[] persistenceUnitPostProcessors) { |
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 should be an ObjectProvider as well.
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.
Oh yes, The change has been made.
| EntityManagerFactoryBuilderCustomizer entityManagerFactoryBuilderCustomizer() { | ||
| return (builder) -> builder.setPersistenceUnitPostProcessors( | ||
| (pui) -> pui.addManagedClassName("customized.attribute.converter.class.name")); | ||
| PersistenceUnitPostProcessor entityManagerFactoryBuilderCustomizer() { |
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 replaces an existing test. I think we should leave it as it is and create a new one that demonstrates the code you've changed.
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.
Yes, absolutely, I have created a new test.
702c81a to
22a47be
Compare
|
We'll have to figure out what we want to do here. I am not 100% sure that registering them from beans is the right call as
Perhaps a more narrowed improvement would be to change I've flagged for team attention so that we can get more feedback before any further change is made. Thanks again. |
|
@snicoll Indeed, adding an "add" would be very interesting. Maybe both approaches are worth adding. |
I think adding an With the customizer approach, there's only one way to apply them; with beans, there would be two - and honestly, I don't see any advantage in that. |
…gerFactoryBuilder Signed-off-by: Lansana DIOMANDE <[email protected]>
22a47be to
5cc0d9e
Compare
|
I'm increasingly not a fan of defining things as beans purely so that they can be registered with something else. With that in mind, I'd vote for methods on the builders and the use of a customizer. |
The goal of this commit is to enable the EntityManagerFactoryBuilder to automatically detect and apply PersistenceUnitPostProcessor beans.
Currently, it is possible to use an EntityManagerFactoryBuilderCustomizer, but since there is no getter providing access to the already registered PersistenceUnitPostProcessor instances, using setPersistenceUnitPostProcessors may unintentionally remove existing ones.