在eclipse中,我得到错误消息“类"test2”已映射,但不包括在任何“中,但是该类包含在持久性xml中。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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_2_0.xsd">
<persistence-unit name="test1">
<class>com.test.domains.test1</class>
<properties>
<!-- properties for schema1 here -->
</properties>
</persistence-unit>
<persistence-unit name="test2">
<class>com.test.test2</class>
<properties>
<!-- properties for schema 2 here -->
</properties>
</persistence-unit>
</persistence>为什么会出现此错误。我必须为两个db模式配置不同的配置吗?
发布于 2012-07-27 21:55:43
Eclipse (或者更具体地说Dali)确实有限制,它不支持两个持久性单元。这也在他们的pages中被告知
目前Dali只支持一个持久化单元和一个持久化
文件。JPA项目中可以存在其他配置,但是当使用多个持久化单元时,验证和默认值处理可能不正确。
至于JPA本身,persistence.xml似乎变得正确了。不需要向两个持久化单元添加相同的类。
https://stackoverflow.com/questions/11689090
复制相似问题