尝试将应用程序部署到Glassfish时收到以下错误。显然我的人际关系有些不对劲。
尝试部署时Glassfish服务器出错:
ValidationException Exception Description: [class edu...clinic.Treatment]
uses a non-entity [class long] as target entity in the relationship attribute
[field providerId]
我的'治疗'类文件中的多对一关系:
@Entiity
...
@ManyToOne
@JoinColumn(name = "provider_fk", referencedColumnName = "npi")
private long providerId;
我的'Provider'类文件中的一对多关系:
@Entity
...
@Id
@Column(name = "NPI")
private long npi;
...
@OneToMany(mappedBy = "providerId", targetEntity=Treatment.class)
@OrderBy
private List<Treatment> treatments;
我相信我的注释是正确的,但有些不对劲。我对如何纠正这一点表示赞赏。
答案 0 :(得分:1)
尝试以下方法, 在治疗实体改变
private long providerId;
到
private Provider provider;
提供者实体更改中的
@OneToMany(mappedBy = "providerId", targetEntity=Treatment.class)
到
@OneToMany(mappedBy = "provider", targetEntity=Treatment.class)