【问题标题】: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);
    

    【讨论】:

      猜你喜欢
      • 2021-02-22
      • 1970-01-01
      • 2016-11-03
      • 2020-05-01
      • 2014-01-15
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      相关资源
      最近更新 更多