Search in sources :

Example 1 with CompanyLogWriteListener

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);
}
Also used : CompanyLogWriteListener(com.ask.springjpaenvers.listener.CompanyLogWriteListener) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry) PostConstruct(javax.annotation.PostConstruct)

Aggregations

CompanyLogWriteListener (com.ask.springjpaenvers.listener.CompanyLogWriteListener)1 PostConstruct (javax.annotation.PostConstruct)1 EventListenerRegistry (org.hibernate.event.service.spi.EventListenerRegistry)1 SessionFactoryImpl (org.hibernate.internal.SessionFactoryImpl)1