Skip to content

Conversation

yrodiere
Copy link
Contributor

@jhoeller Hi! I think you're the one to ping regarding this part of the code? We've talked previously in #21548.

This PR:

  • Adds more extensive tests for SpringBeanContainer
  • Fixes a bug where SpringBeanContainer would forget to autowire bean properties when a bean is requested by name (org.springframework.orm.jpa.hibernate.HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests#testCanRetrieveBeanByNameWithJpaCompliantOptions was failing)
  • Fixes a bug where SpringBeanContainer would simply ignore the name when a bean is requested by name (the tests org.springframework.orm.jpa.hibernate.HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests#testCanRetrieveFallbackBeanByName* were failing). If it was only about internal Spring behavior, it would be fine, but it also affected how the fallback producer was used. Essentially, whenever a bean name didn't match anything in Spring, SpringBeanContainer would first try to ignore the name, and if that failed it would call org.hibernate.resource.beans.spi.BeanInstanceProducer#produceBeanInstance(java.lang.Class<B>), not passing the name to the fallback bean producer.

Note that the fixes should not affect current setups, because Hibernate ORM currently never requests named beans,. The concept of named beans in ORM SPIs was added with future changes in mind, and is currently being leveraged in Hibernate Search 6 (still in Alpha).

@pivotal-issuemaster
Copy link

@yrodiere Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@yrodiere Thank you for signing the Contributor License Agreement!

@jhoeller jhoeller self-assigned this Jan 21, 2019
@jhoeller jhoeller added this to the 5.1.5 milestone Jan 21, 2019
@yrodiere
Copy link
Contributor Author

Just rebased on master and fixed the problems reported by codacy.

@jhoeller jhoeller added the type: bug A general bug label Jan 24, 2019
@jhoeller
Copy link
Contributor

jhoeller commented Feb 4, 2019

@yrodiere this looks good to me so far, it just seems that some Hibernate search copyright headers sneaked into the test classes? Could you update all copyright headers to the common Spring one, ideally with copyright range -2019?

@yrodiere
Copy link
Contributor Author

yrodiere commented Feb 5, 2019

@jhoeller That was an oversight, sorry. I force-pushed an update, all should be good now.

@jhoeller jhoeller merged commit 00855c4 into spring-projects:master Feb 5, 2019
jhoeller pushed a commit that referenced this pull request Feb 5, 2019
… the behavior when requesting named beans (#22260)

* Add integration tests for SpringBeanContainer (Hibernate ORM integration)
* Autowire bean properties of beans retrieved by name in SpringBeanContainer
* Add integration tests for fallback cases in SpringBeanContainer (Hibernate ORM integration)
* Fix SpringBeanContainer incorrectly losing the bean name when calling the fallback producer

(cherry picked from commit 00855c4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants