vendredi 8 mai 2015

Creating EntityManagerFactory from hibernate Configuration

In our current application (java se) we use Hibernate specific api, but we kind of want to migrate to JPA wherever possible (but slowly). For that, I need EntityManagerFactory instead of SessionFactory (and I would like to keep this an axiom without dispute).

Where is the problem is, that currently our session factory is being created from org.hibernate.cfg.Configuration and I would like to keep it as it for now - as this configuration is passed thru different parts of our software which can and do configure the persistence as they want.

So the question is: how can I make

ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings( hibConfiguration.getProperties() ).buildServiceRegistry();
SessionFactory sessionFactory = hibConfiguration.buildSessionFactory( serviceRegistry );

equivalent resulting in EntityManagerFactory ?

Aucun commentaire:

Enregistrer un commentaire