Sunday, September 19, 2010

How to inject a spring's service bean into a JPA Entity ?

Programmer Question

My problem is very similar to this one : Injecting fields via Spring into entities loaded by Hibernate



The difference is that , I am using JPA2 entities , not hibernate . While the underlayer is still hibernate (3.5.5).



My spring version is 3.0.4.



What's the corresponding eventListeners in JPA's world ?



Sample code from the original post :



class Student {
int id; //loaded from DB
String name; //loaded from DB
int injectedProperty; //Inject via Spring
Service serviceImpl; //Inject via Spring
}


I know there may be aspectJ's solutions , but I'd rather like a pure-java solution.
Thanks.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails