我的 TableX 引用了 TableY。

@JoinColumn(name = "idTableY", referencedColumnName = "idTableY")
@ManyToOne(optional = false, fetch=FetchType.LAZY)
private TableY idTableY;

我收到这个错误。
<openjpa-2.0.0-r422266:935683 fatal user error> org.apache.openjpa.persistence.ArgumentException
"com.mycompany.entities.TableX.idTableY" has columns with targets, but OpenJPA does not support any joins on this mapping in this context.

表 Y 有这个代码:
 @OneToMany(cascade = CascadeType.ALL, mappedBy = "idTableY")
    private Collection<TableX> tableXCollection;

这个生成的 eclipse-link 代码是 100% 正常的(所有其他具有类似代码的实体/表都没有问题)。

但是其中一些会出现此类错误。知道为什么吗?

最佳答案

尝试删除不必要的 @JoinColumn 定义。包含外键的连接列是自动生成的。实体不是表,它们是两种不同的东西。实体是映射到数据库表上的类。

关于jpa - 这是什么 JPA 错误以及如何修复它?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8451242/

10-10 09:36