如图,无法设置栏目名称 我使用 Hibernate 6.4.4
我正在尝试在帐户和人员之间创建关系,但收到错误“无法解析列'accound_id'”,我已经完成了映射,但仍然收到上述错误。
<mapping class="com.bravos2k5.models.Account"/>
<mapping class="com.bravos2k5.models.Person"/>
账户类别: @实体 公开课帐号{
@Getter
@Setter
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Getter
@Setter
@Column(nullable = false, unique = true, updatable = false)
private String username;
@Getter
@Setter
@Column(nullable = false)
private String password;
@Getter
@Setter
@Column(unique = true)
private String email;
@Getter
@Setter
@Column(unique = true)
private String phone;
@Getter
@Setter
@OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
private List<Person> personList = new ArrayList<>();
private Boolean isBan;
public void setBan(Boolean isBan) {
this.isBan = isBan;
}
public Boolean isBan() {
return isBan;
}
public Account() {}
public Account(String username, String password, String email, String phone, Boolean isBan) {
this.username = username;
this.password = password;
this.email = email;
this.phone = phone;
this.isBan = isBan;
}
public Account(String username) {
this.username = username;
}
}
人物类别:
@Entity
@Getter
@Setter
public class Person {
public static boolean FEMALE = false;
public static boolean MALE = true;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private Boolean gender;
@ManyToOne
@JoinColumn(name = "account_id") // Problem here
private Account account;
public Person() {
}
}
请帮我解决这个问题
答案就在你的问题中:
在您的数据库中,您有一张用于
Person
实例的表。其中每一个都通过人员表中的 Account
列与最多一个 account_id
实例关联。该栏目不存在。
你能做的是: