spring-roo

Injecting a Spring dependency into a JPA EntityListener

我只是一个虾纸丫 提交于 2019-11-26 18:37:26
I am trying to inject a Spring dependency into an JPA EntityListener . Here is my listener class: @Configurable(autowire = Autowire.BY_TYPE, dependencyCheck = true) public class PliListener { @Autowired private EvenementPliRepository evenementPliRepository; @PostPersist void onPostPersist(Pli pli) { EvenementPli ev = new EvenementPli(); ev.setPli(pli); ev.setDateCreation(new Date()); ev.setType(TypeEvenement.creation); ev.setMessage("Création d'un pli"); System.out.println("evenementPliRepository: " + evenementPliRepository); evenementPliRepository.save(ev); } } Here is my Entity class:

Injecting a Spring dependency into a JPA EntityListener

╄→гoц情女王★ 提交于 2019-11-26 04:39:46
问题 I am trying to inject a Spring dependency into an JPA EntityListener . Here is my listener class: @Configurable(autowire = Autowire.BY_TYPE, dependencyCheck = true) public class PliListener { @Autowired private EvenementPliRepository evenementPliRepository; @PostPersist void onPostPersist(Pli pli) { EvenementPli ev = new EvenementPli(); ev.setPli(pli); ev.setDateCreation(new Date()); ev.setType(TypeEvenement.creation); ev.setMessage(\"Création d\'un pli\"); System.out.println(\