我正在尝试保留一个列表,但是我收到了这个错误
org.hibernate.MappingException: Could not determine type for: java.util.List, at table: Person, for columns: [org.hibernate.mapping.Column(comments)]
我使用了 hibernate 文档中指定的 @ElementCollection 注释。我看不出还有什么可以尝试的。
请忽略这一段只是为了让我可以提交问题。
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.stereotype.Component;
@Component
@Entity
public class Person {
private String name;
private Long id;
private String reviewName;
private String review;
private List<String> comments = new ArrayList<String>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Id
@GeneratedValue(generator="increment")
@GenericGenerator(name="increment", strategy="increment")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(columnDefinition="LONGTEXT")
public String getReview() {
return review;
}
public void setReview(String review) {
this.review = review;
}
public String getReviewName() {
return reviewName;
}
public void setReviewName(String reviewName) {
this.reviewName = reviewName;
}
public List<String> getComments() {
return comments;
}
@ElementCollection
public void setComments(List<String> comments) {
this.comments = comments;
}
public void addComment(String comment) {
getComments().add(comment);
}
}