我正在弄清楚如何使用@OneToMany和@ManyToOne,并弄清楚为什么不将@Column放在我的实体模型的所有字段之上。唯一的问题是我得到“无法解析列'...'”。
我的项目如下:
内部:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "house_id") //error here
private long houseId;
private String address;
private String houseNumber;
private String city;
//@OneToMany(mappedBy = "person")
private List<Person> people;
亲临:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(unique = true)
private long personId;
@Column(nullable = false)
private String fullName;
private String phoneNumber;
@ManyToOne
@JoinColumn(name = "houseId")//error here as well
private House house;
我试图分配数据源,但是显示的唯一持久性单元是entityManagerFactory,并且不会进一步扩展。但是当我去查看=>工具Windows =>持久性时,它确实显示了更多。我就是不知道该怎么解决。
编辑:如果我将unique = true
放在name = "id"
之前,则不会出现错误,但是我仍然会在@JoinColumn上看到错误。