use of org.hibernate.event.service.spi.EventListenerRegistry 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));
}
use of org.hibernate.event.service.spi.EventListenerRegistry 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);
}
use of org.hibernate.event.service.spi.EventListenerRegistry in project hibernate-search by hibernate.
the class FullTextSessionBuilder method build.
/**
* Builds the sessionFactory as configured so far.
*/
public FullTextSessionBuilder build() {
V5MigrationHelperOrmSetupHelper.SetupContext setupContext = setupHelper.start();
setupContext = setupContext.withProperties(cfg);
setupContext = setupContext.withConfiguration(builder -> builder.addAnnotatedClasses(annotatedClasses));
sessionFactory = setupContext.setup().unwrap(SessionFactoryImplementor.class);
ServiceRegistryImplementor serviceRegistryImplementor = sessionFactory.getServiceRegistry();
EventListenerRegistry registry = serviceRegistryImplementor.getService(EventListenerRegistry.class);
for (LoadEventListener listener : additionalLoadEventListeners) {
registry.getEventListenerGroup(EventType.LOAD).appendListener(listener);
}
return this;
}
use of org.hibernate.event.service.spi.EventListenerRegistry in project cdmlib by cybertaxonomy.
the class CdmHibernateListenerConfiguration method taxonGraphHibernateListener.
@Bean
public TaxonGraphHibernateListener taxonGraphHibernateListener() {
TaxonGraphHibernateListener taxonGraphHibernateListener = new TaxonGraphHibernateListener();
EventListenerRegistry listenerRegistry = ((SessionFactoryImpl) sessionFactory).getServiceRegistry().getService(EventListenerRegistry.class);
listenerRegistry.appendListeners(EventType.POST_UPDATE, taxonGraphHibernateListener);
listenerRegistry.appendListeners(EventType.POST_INSERT, taxonGraphHibernateListener);
listenerRegistry.appendListeners(EventType.PRE_DELETE, taxonGraphHibernateListener);
return taxonGraphHibernateListener;
}
use of org.hibernate.event.service.spi.EventListenerRegistry 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);
}
Aggregations