Search in sources :

Example 1 with RevisionHistoryEventListener

use of com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener in project toy by gmoon92.

the class JpaConfig method init.

@PostConstruct
public void init() {
    SessionFactoryImpl sessionFactory = entityManagerFactory.unwrap(SessionFactoryImpl.class);
    EventListenerRegistry registry = sessionFactory.getServiceRegistry().getService(EventListenerRegistry.class);
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    RevisionHistoryEventListener revisionHistoryEventListener = new RevisionHistoryEventListener(entityManager);
    registry.appendListeners(EventType.POST_COMMIT_INSERT, revisionHistoryEventListener);
}
Also used : EntityManager(javax.persistence.EntityManager) RevisionHistoryEventListener(com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry) PostConstruct(javax.annotation.PostConstruct)

Example 2 with RevisionHistoryEventListener

use of com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener in project toy by gmoon92.

the class JPAEventListenerIntegrator method integrate.

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
    final EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
    EntityManager em = sessionFactory.createEntityManager();
    listenerRegistry.appendListeners(EventType.POST_COMMIT_INSERT, new RevisionHistoryEventListener(em));
}
Also used : EntityManager(javax.persistence.EntityManager) RevisionHistoryEventListener(com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry)

Example 3 with RevisionHistoryEventListener

use of com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener in project Toy by gmoon92.

the class JpaConfig method init.

@PostConstruct
public void init() {
    SessionFactoryImpl sessionFactory = entityManagerFactory.unwrap(SessionFactoryImpl.class);
    EventListenerRegistry registry = sessionFactory.getServiceRegistry().getService(EventListenerRegistry.class);
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    RevisionHistoryEventListener revisionHistoryEventListener = new RevisionHistoryEventListener(entityManager);
    registry.appendListeners(EventType.POST_COMMIT_INSERT, revisionHistoryEventListener);
}
Also used : EntityManager(javax.persistence.EntityManager) RevisionHistoryEventListener(com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry) PostConstruct(javax.annotation.PostConstruct)

Example 4 with RevisionHistoryEventListener

use of com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener in project Toy by gmoon92.

the class JPAEventListenerIntegrator method integrate.

@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
    final EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
    EntityManager em = sessionFactory.createEntityManager();
    listenerRegistry.appendListeners(EventType.POST_COMMIT_INSERT, new RevisionHistoryEventListener(em));
}
Also used : EntityManager(javax.persistence.EntityManager) RevisionHistoryEventListener(com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry)

Aggregations

RevisionHistoryEventListener (com.gmoon.hibernateenvers.global.envers.listener.RevisionHistoryEventListener)4 EntityManager (javax.persistence.EntityManager)4 EventListenerRegistry (org.hibernate.event.service.spi.EventListenerRegistry)4 PostConstruct (javax.annotation.PostConstruct)2 SessionFactoryImpl (org.hibernate.internal.SessionFactoryImpl)2