Code example for SessionFactoryImpl

Methods: getServiceRegistry

0
		 
		entityManagerFactory = Persistence.createEntityManagerFactory("hibernate4-changesetmerge-pu", props);
		 
		try { 
			SessionFactoryImpl sessionFactory = (SessionFactoryImpl)entityManagerFactory.getClass().getMethod("getSessionFactory").invoke(entityManagerFactory);
			EventListenerRegistry registry = sessionFactory.getServiceRegistry().getService(EventListenerRegistry.class);
			registry.setListeners(EventType.MERGE, new HibernateDataChangeMergeListener());
		} 
		catch (Exception e) {
			throw new RuntimeException("Could not init persistence", e);
		} 
	} 
 
	@Override 
	protected void open() { 
		entityManager = entityManagerFactory.createEntityManager();
		tx = entityManager.getTransaction();
		tx.begin();
	} 
	@Override 
Connect your IDE to all the code out there  Get Codota for Java