Hibernate ORM SessionFactoryImpl - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM SessionFactoryImpl class.

This code example shows how to use the following methods:getServiceRegistry
		 
		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 
5
CodeRank