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 ?).

Comment From: snicoll

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.

Comment From: snicoll

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

Comment From: sdeleuze

Could we maybe document that in the Javadoc?

Comment From: snicoll

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.