为了账号安全,请及时绑定邮箱和手机立即绑定

将实体绑定到具有 2 个数据源的特定持久性单元

将实体绑定到具有 2 个数据源的特定持久性单元

倚天杖 2021-06-20 12:01:58
我有两个持久性单元persistence.xml和两个数据源,standalone.xml但我无法将表 A 绑定到持久性 1,将表 B 绑定到持久性 2像这样<persistence-unit name="itsetup-persistence-unit-dev1" transaction-type="JTA">    <description>Forge Persistence Unit</description>    <provider>org.hibernate.ejb.HibernatePersistence</provider>    <jta-data-source>java:/itsetup-dev1</jta-data-source>    ...<persistence-unit name="itsetup-persistence-unit-dev3" transaction-type="JTA">    <description>Forge Persistence Unit</description>    <provider>org.hibernate.ejb.HibernatePersistence</provider>    <jta-data-source>java:/itsetup-dev3</jta-data-source>    <class>my.package.User</class>    <exclude-unlisted-classes>true</exclude-unlisted-classes>    ...和<datasource jndi-name="java:/itsetup-dev3" pool-name="itsetup-dev3" enabled="true" use-java-context="true">    <connection-url>jdbc:informix-sqli://server:9991/database</connection-url>    <driver-class>com.informix.jdbc.IfxDriver</driver-class>    <driver>ifxjdbc.jar</driver>    <security>    ...这是我的用户模型@Entity@PersistenceContext(unitName = "itsetup-persistence-unit-dev3")@Table(name = "user_file")public class User {我的用户服务在哪里@PersistenceContext(unitName = "itsetup-persistence-unit-dev3")private EntityManager em;课程表是@Entity@PersistenceContext(unitName = "itsetup-persistence-unit-dev1")@Table(name = "ppp_course")public class Course {和我的课程服务@PersistenceContext(unitName = "itsetup-persistence-unit-dev1")private EntityManager em;但是当我运行服务器时,它总是将其他表生成到 dev3 数据库中,就像它没有查看 dev1 数据库一样 Table not found: ppp_course我怎么能解决这个问题?
查看完整描述

1 回答

?
忽然笑

TA贡献1806条经验 获得超5个赞

删除<property name="hibernate.archive.autodetection" value="class" /><persistence-unit name="itsetup-persistence-unit-dev3" transaction-type="JTA">。但不得不失去自动检测功能。


查看完整回答
反对 回复 2021-06-23
  • 1 回答
  • 0 关注
  • 112 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信