Skip to content

org.springframework.orm.hibernate5.SpringBeanContainer ignores the fallback bean instance producer [SPR-17010] #21548

Closed
@spring-projects-issues

Description

@spring-projects-issues

Yoann Rodiere opened SPR-17010 and commented

#20852 added support for Hibernate ORM's BeanContainer SPI, but the implementation ignores one of the parameters passed to the bean container: fallbackProducer. Hibernate ORM expects implementors to use this fallback producer whenever a bean could not be found (i.e., in the case of Spring, when the bean factory throws something like a BeanNotFoundException, I think).

Why it can be useful: for example, Hibernate Search uses the same SPI to instantiate some required beans, but provides a specific fallbackProducer which may in particular take advantage of a legacy annotation (@Factory, example). Even with advanced default behavior inside Spring's BeanFactory, Spring cannot reasonably be expected to understand that kind of annotation.

Ignoring this fallbackProducer parameter means that users migrating to Spring 5.1.RC1 who used to instantiate their beans through reflections or features native to Hibernate may have errors on startup because Spring doesn't find some beans, even though Hibernate would be able to find the beans by itself if given the chance.

 

An example of what was expected can be found in the CDI implementation built in Hibernate ORM: 

As for tests, the built-in CDI implementation tests this exact feature (fallback instantiation) there: https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/test/java/org/hibernate/test/cdi/general/nonregistrymanaged/standard/NonRegistryManagedStandardCdiSupportTest.java#L110


Affects: 5.1 RC1

Issue Links:

Referenced from: commits d2eb4d2

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions