类“部门”已映射,但不包含在任何持久性单元中
我收到此错误,但不知道原因:“部门”类已映射,但不包含在任何持久性单元中。
我有两个项目。 一是在我的 persistence.xml 中,标记之间只有两行:
<persistence-unit name="UserJPA">
</persistence-unit>
我的类是:
package br.com.jm.user;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;;
@Entity
@Table(name = "DEPARTMENT")
public class Department implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id;
private String name;
//getters and setters
}
我正在使用 EclipseLink2.1.2。事实上,如果它能让事情变得更容易的话,我可以删除它。
拥抱, 德梅特里奥
I am getting this error and I have no idea the reason: Class "Department" is mapped, but is not included in any persistence unit.
I have two project.
One is In my persistence.xml, between tag, there is only two lines:
<persistence-unit name="UserJPA">
</persistence-unit>
My class is:
package br.com.jm.user;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;;
@Entity
@Table(name = "DEPARTMENT")
public class Department implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id;
private String name;
//getters and setters
}
I am using EclipseLink2.1.2. Actually I can remove this if it makes the things easier.
Hugs,
Demetrio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(4)
萌酱2024-11-20 10:52:00
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_2_0.xsd"
version="2.0">
<persistence-unit>..</persistence-unit>
</persistence>
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
对于在 Eclipse 或 RAD 中搜索“类 xxxx 已映射,但未包含在任何持久性单元中”错误时发现此老问题的任何人,请参阅 这个问题和答案有适合我的解决方案:
这些步骤对我有用。
For anyone who finds this old question when searching for the "Class xxxx is mapped, but is not included in any persistence unit" error in Eclipse or RAD, a comment on this question and answer has the solution that worked for me:
These steps worked for me.