【发布时间】:2020-01-02 11:55:06
【问题描述】:
当我运行程序时抛出了一个 PSQLExecption,我试图跟踪它,但找不到导致此异常的原因。我尝试添加一个模式和实体名称,正如我在其他帖子中看到的那样,但没有没用
@Entity
@Table(name = "Category" , schema = "schem")
public class Category {
@OneToMany(mappedBy = "category")
public List<Question> questions;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CID")
private Long categoryId;
@Column(name = "CName", unique = true)
private String categoryName;
public Category() {
questions = new ArrayList<>();
}
public Long getCategoryId() {
return categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Category)) {
return false;
}
Category category = (Category) o;
return getCategoryName().equals(category.getCategoryName());
}
@Override
public int hashCode() {
return Objects.hash(getCategoryName());
}
}
【问题讨论】:
-
您是通过脚本创建表格还是自动生成表格?
-
数据持久化时使用entitymanager创建表
标签: java postgresql jpa orm