【问题标题】:JPA EclipseLink uses a non-entity as target entity in the relationship attributeJPA EclipseLink 在关系属性中使用非实体作为目标实体
【发布时间】: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


【解决方案1】:

我只用查找和替换重命名了孔项目。问题是在ear 项目中依赖于一个旧的.war 文件,该文件中有一个persistence.xml。刚刚删除了旧的依赖项和 BOOM。现在我只需要修复其他错误消息(“com.Profile[id = null] 不是已知的实体类型”)

【讨论】:

    猜你喜欢
    • 2017-05-22
    • 2015-02-09
    • 1970-01-01
    • 2012-01-11
    • 2015-01-14
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多