【发布时间】:2012-03-22 22:07:35
【问题描述】:
我有以下情况:
- 项目 A - 包含几个实体并且是独立的
- 项目 B - 包含几个实体并且是独立的
- 项目 C - 包含少量实体并依赖于项目 A 和项目 B。
我正在使用 Maven 来管理依赖项和构建。
当我尝试测试项目 A 和项目 B 时,它运行良好。它们每个都有一个 persistence.xml 和一个单独的持久化上下文。
当我运行 Project C 时,它会映射任何实体。我尝试使用自动检测,指定 jar 文件属性...但似乎没有任何效果。
它给了我一个映射异常,说未知实体,不会持久化或读取项目 A 或 B 中的实体。我已在此处发布了 3 个 persistence.xml 文件。
另外,我尝试使用类属性并使用相同的持久上下文,但它就是找不到文件。
非常感谢任何帮助。
提前致谢!
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="A" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.username" value="username"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@webdev.epi.web:1521/webdev.world"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
</persistence>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="B" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.username" value="username"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@webdev.epi.web:1521/webdev.world"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
</persistence>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="C" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jar-file>A-0.0.1-SNAPSHOT.jar</jar-file>
<jar-file>B-0.0.1-SNAPSHOT.jar</jar-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.connection.username" value="username"/>
<property name="hibernate.connection.password" value="password"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@webdev.epi.web:1521/webdev.world"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.archive.autodetection" value="class"/>
</properties>
</persistence-unit>
</persistence>
【问题讨论】:
标签: hibernate jpa hibernate-mapping