作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
出现以下异常,为什么我不知道,请帮我解决它
Exception in thread "main" org.hibernate.MappingException: Could not determine type for: java.util.List, at table: USER_DETAIL, for columns: [org.hibernate.mapping.Column(listOfAddress)]
@Entity
@Table (name="USER_DETAIL")
public class UsersDetail {
private int id; //
@Column (name ="NAME")
private String name;
@ElementCollection
private List<Address> listOfAddress = new ArrayList<Address>();
@Id @GeneratedValue
@Column (name ="ID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Address> getListOfAddress() {
return listOfAddress;
}
public void setListOfAddress(List<Address> listOfAddress) {
this.listOfAddress = listOfAddress;
}}
最佳答案
您好,我认为问题出在注释的位置上。您正在使用方法访问策略(由@Id注释确定)。将任何与 JPA 相关的注释放在每个 getter 的正上方,而不是字段成员的上方。
如下:-
@Column (name ="NAME")
public String getName() {
return name;
}
@ElementCollection
public List<Address> getListOfAddress() {
return listOfAddress;
}
关于java - 在 Hibernate 中将集合中的映射异常另存为成员变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30611446/
我有 json 数据: { "products": [ { "productId" : 0, "productImg" : "../img/product-ph
我是一名优秀的程序员,十分优秀!