相关疑难解决方法(0)

JPA使用替代"persistence.xml"

我知道这有说明:

Persistence.createEntityManagerFactory("persistence-unit-name");
Run Code Online (Sandbox Code Playgroud)

JPA持久性机制读取"persistence.xml"文件,查找名为"persistence-unit-name"的持久性单元,并基于它构造EntityManagerFactory.

我的问题是,如何强制JPA 采用与"persistence.xml"不同的文件?例如,"persistence-test.xml".

java hibernate ejb jpa

21
推荐指数
2
解决办法
3万
查看次数

以编程方式创建实体管理器而不持久化文件

我正在尝试以编程方式创建实体工厂管理器而不使用持久性文件

    EntityManagerFactory emf;
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
    properties.put("hibernate.connection.url", "jdbc:mysql://173.194.25***************");
    properties.put("hibernate.connection.username", "etech****");
    properties.put("hibernate.connection.password", "A*****");
    properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
    properties.put("hibernate.show-sql", "true");
    properties.put("provider", "org.hibernate.ejb.HibernatePersistence");
    emf = Persistence.createEntityManagerFactory(idClient, properties);
Run Code Online (Sandbox Code Playgroud)

在线

emf = Persistence.createEntityManagerFactory(idClient, properties);
Run Code Online (Sandbox Code Playgroud)

我收到错误:

org.springframework.beans.factory.BeanCreationException:创建名为'com****RepositoryFieldsFieldWorkerRepositoryImpl'的bean时出错:init方法的调用失败; 嵌套异常是javax.persistence.PersistenceException:没有名为idClient的EntityManager的持久性提供程序

我该如何解决这个问题?

任何帮助将不胜感激

java entity hibernate entitymanager eclipselink

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

hibernate ×2

java ×2

eclipselink ×1

ejb ×1

entity ×1

entitymanager ×1

jpa ×1