use of com.ask.springjpaenvers.listener.CompanyLogWriteListener in project tutorials by csh0034.
the class JpaConfig method init.
@PostConstruct
public void init() {
SessionFactoryImpl sessionFactory = emf.unwrap(SessionFactoryImpl.class);
EventListenerRegistry registry = sessionFactory.getServiceRegistry().getService(EventListenerRegistry.class);
CompanyLogWriteListener logWriteListener = new CompanyLogWriteListener(companyLogService);
registry.appendListeners(EventType.POST_INSERT, logWriteListener);
registry.appendListeners(EventType.POST_UPDATE, logWriteListener);
registry.appendListeners(EventType.POST_DELETE, logWriteListener);
}
Aggregations