Skip to content

@ImportRuntimeHints does not work on AbstractEntityManagerFactoryBean #29145

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

Closed
sdeleuze opened this issue Sep 13, 2022 · 4 comments
Closed

@ImportRuntimeHints does not work on AbstractEntityManagerFactoryBean #29145

sdeleuze opened this issue Sep 13, 2022 · 4 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply theme: aot An issue related to Ahead-of-time processing type: bug A general bug

Comments

@sdeleuze
Copy link
Contributor

While working on #29138, I found that a @ImportRuntimeHints(EntityManagerRuntimeHints.class) annotation on AbstractEntityManagerFactoryBean was not taken in account in the data-jpa smoke test sample. So I tried adding it to LocalEntityManagerFactoryBean and LocalContainerEntityManagerFactoryBean, but same result. I ended-up registering via aot.factories but it would be nice to understand why this does not work (FactoryBean, InitializingBean ?).

@sdeleuze sdeleuze added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing labels Sep 13, 2022
@sdeleuze sdeleuze added this to the 6.0.0-RC1 milestone Sep 13, 2022
@snicoll
Copy link
Member

snicoll commented Sep 30, 2022

It doesn't work because we use beanFactory#findAnnotationOnBean and that looks for the underlying type, not the FactoryBean itself. It can be dangerous to rely on the factory bean as it might not be exposed in certain cases and therefore the hints can be lost.

@snicoll
Copy link
Member

snicoll commented Sep 30, 2022

For the reason above I am going to decline this for now.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2022
@snicoll snicoll removed this from the 6.0.0-RC1 milestone Sep 30, 2022
@snicoll snicoll added the status: declined A suggestion or change that we don't feel we should currently apply label Sep 30, 2022
@sdeleuze
Copy link
Contributor Author

sdeleuze commented Oct 2, 2022

Could we maybe document that in the Javadoc?

@snicoll
Copy link
Member

snicoll commented Oct 3, 2022

I don't think we should really. "the annotated component or bean method" already covers the use case here. A factory bean is not the component that it produces but a transient artifact. We can maybe clarify by providing more examples if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants