What is the replacement for EntityManagerFactoryRegistry.getNamedEntityManagerFactory in hibernate 5.x

56 Views Asked by At

I was using EntityManagerFactoryRegistry.getNamedEntityManagerFactory from hibernate-entitymanager:4.2.18 but when i update to 5.x i see that this class is no longer available. In fact hibernate-entitymanager itself is obsolete in hibernate 5.x. So my question is what is the replacement for this in v5.x? Any idea?

1

There are 1 best solutions below

0
JMBA On

Just in case if someone is searching for an answer, below worked for me

Map<String, String> properties = new HashMap<>();
    properties.put("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
    properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");
    properties.put("hibernate.show_sql", "false");
    properties.put("hibernate.connection.url", DB_URI);
    properties.put("hibernate.connection.username", DB_USER.toUpperCase(Locale.ROOT));
    properties.put("hibernate.connection.password", DB_USER.toUpperCase(Locale.ROOT));
EntityManagerFactory emf  =
 Persistence.createEntityManagerFactory(ENTITY_MANAGER_FACTORY_LOCAL_TEST, properties);