【问题标题】:What is the replacement for EntityManagerFactoryRegistry.getNamedEntityManagerFactory in hibernate 5.xhibernate 5.x 中 EntityManagerFactoryRegistry.getNamedEntityManagerFactory 的替代品是什么
【发布时间】:2022-01-22 03:01:54
【问题描述】:
我使用的是 hibernate-entitymanager:4.2.18 中的 EntityManagerFactoryRegistry.getNamedEntityManagerFactory 但是当我更新到 5.x 时,我发现这个类不再可用。事实上,hibernate-entitymanager 本身在 hibernate 5.x 中已经过时了。
所以我的问题是 v5.x 中的替代品是什么?有什么想法吗?
【问题讨论】:
标签:
jpa-2.0
hibernate-5.x
【解决方案1】:
以防万一有人在寻找答案,下面对我有用
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);