Skip to content

HibernateJpaAutoConfiguration does not back off despite LocalContainerEntityManagerFactory beans being declared manually #5542

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

Open
odrotbohm opened this issue Mar 31, 2016 · 4 comments
Labels
type: enhancement A general enhancement

Comments

@odrotbohm
Copy link
Member

If you remove the manual exclusion for the HibernateJpaAutoConfiguration here the application bootstrap will blow up trying to apply the auto configuration and failing to wire the unique DataSource expected to be present. I wonder why the configuration is getting applied in the first place, as I would've expected the manual declarations of LocalContainerEntityManagerFactoryBeans here and here to disable the auto-configuration in the first place.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 31, 2016
@wilkinsona
Copy link
Member

HibernateJpaAutoConfiguration creates more than just a LocalContainerEntityManagerFactoryBean so I don't think it would be appropriate for everything to back off purely because there's a user-declared LocalContainerEntityManagerFactoryBean in the context.

That said, the LocalContainerEntityManagerFactoryBean is the only auto-configured bean that depends on the DataSource so it might be possible to restructure things so that only that bean backs off when there are multiple DataSource beans in the context. That would make this a duplicate of #5541.

@odrotbohm
Copy link
Member Author

Yeah, I've seen EntityManagerFactoryBuilder being created, which would indeed be helpful to even set up the manually declared instances. If we could untangle those parts, perfect!

@wilkinsona wilkinsona self-assigned this Apr 19, 2016
@wilkinsona
Copy link
Member

An interesting side-effect of isolating the auto-configuration of the LocalContainerEntityManagerFactoryBean to be the only part that requires a DataSource is that you then get various JPA-related beans being auto-configured even if there's no DataSource in the context. We could almost do with it all being conditional on at least one DataSource bean and then the LocalContainerEntityManagerFactoryBean being conditional on a single DataSource.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Apr 19, 2016
@philwebb philwebb added type: enhancement A general enhancement and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels May 19, 2016
@philwebb
Copy link
Member

This turns out to be not so easy. We'll need a bit more time to play with some ideas so it's unlikely to make 1.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants