Injecting fields via Spring into entities loaded by Hibernate

前端 未结 4 881
臣服心动
臣服心动 2020-12-14 08:54

I am looking for a way to inject certain properties via Spring in a bean that is loaded from the DB by Hibernate.

E.g.

class Student {
   int id; //l         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-14 09:48

    You can inject the dependency into the hibernate DAO bean for the entity and set the property on the entity before returning it from the DAO.

    This will only work if you are loading the entity from the DAO

提交回复
热议问题