【发布时间】:2015-06-07 03:08:49
【问题描述】:
当我尝试在 glassfish 4.1 上部署我的应用程序时出现以下错误:
[class com.sample.model.Profile] uses a non-entity [class com.sample.model.ProfileEventMapping] as target entity in the relationship attribute [field events].
正在数据库中创建两个实体的表。
简介:
@Entity
public class Profile
...
@OneToMany(mappedBy = "profile", orphanRemoval = true)
private Set<ProfileEventMapping> events = new HashSet<>();
ProfileEventMapping:
@Entity
public class ProfileEventMapping
...
@NotNull
@ManyToOne
private Profile profile;
在我的 persistence.xml 中,我选择包含所有实体:
<exclude-unlisted-classes>false</exclude-unlisted-classes>
有人有想法吗?
【问题讨论】:
-
不确定这是否与问题有关,但我刚刚注意到 ProfileEventMapping 中的 Profile 用 OneToOne 注释,这应该是 ManyToOne。
-
谢谢我复制错了。与错误无关。
-
请尝试从 persistence.xml 中删除
。容器无论如何都会选择带注释的实体 -
试过它并没有改变任何东西。仍然收到错误。 persistence.xml 是从 netbeans 生成的
-
如何打包实体?检查两个类文件是否在相对于正在使用的 persistence.xml 文件的同一位置可用,尤其是在 jar 中时。
标签: jpa eclipselink java-ee-7 glassfish-4.1