我正在使用JPA和eclipselink从表生成实体,但问题是ManyToOne案例中的外键不是由JPA管理的。我正在使用Postgres数据库。我在下面添加了代码:
@Entity
@Table(name="\"Commande\"")
@NamedQuery(name="Commande.findAll", query="SELECT c FROM Commande c")
public class Commande implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="\"idCmd\"")
private Integer idCmd;
@Column(name="\"idClt\"")
private Integer idClt;
//bi-directional many-to-one association to Client
@ManyToOne
@JoinColumns({
})
private Client client;
public Commande() {
}
答案 0 :(得分:0)
我找到了解决方案,我只是添加: @JoinColumn(name =" \" idClt \"",insertable = false,updatable = false), 它现在有效!