private void insertValidationEventListeners(Injector injector) {
javax.inject.Provider<EntityManagerFactory> emfProvider =
injector.getProvider(EntityManagerFactory.class);
HibernateEntityManagerFactory hibernateEntityManagerFactory =
(HibernateEntityManagerFactory) emfProvider.get();
SessionFactoryImpl sessionFactoryImpl =
(SessionFactoryImpl) hibernateEntityManagerFactory.getSessionFactory();
EventListenerRegistry registry =
sessionFactoryImpl.getServiceRegistry().getService(EventListenerRegistry.class);
javax.inject.Provider<BeanValidationEventListener> listenerProvider =
injector.getProvider(BeanValidationEventListener.class);
registry.getEventListenerGroup(EventType.PRE_INSERT).appendListener(listenerProvider.get());
registry.getEventListenerGroup(EventType.PRE_UPDATE).appendListener(listenerProvider.get());