Reputation: 41300
In JPA I want to utilize the PrePersist
annotated method to perform some operations but rather than making the things it needs to implement the Singleton pattern (with getInstance() etc.) I was wondering if I pass the Spring ApplicationContext through a ThreadLocal (which I close release after the request) would be a safe thing to do so. I am only using it primarilly to getBean(Support.class)
and not modifying the context.
Upvotes: 0
Views: 587
Reputation: 10075
If you can use Hibernate event listeners I wrote once a response with a possible approach for Spring managed event listeners here:
Using Hibernate 4's Integrator pattern and Spring's dependency injection
Upvotes: 1