无法确定表…;中的java.util.List的类型;,对于列:[org.hibernate.mapping.Column(…;)]
试图将消息与许多评论关联,但出现错误:无法确定表…;中的java.util.List的类型;,对于列:[org.hibernate.mapping.Column(…;)],hibernate,jpa,Hibernate,Jpa,试图将消息与许多评论关联,但出现错误: An Error Occurred: [PersistenceUnit: persistence] Unable to build Hibernate SessionFactory Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: message, for columns: [org.hibernate.map
An Error Occurred:
[PersistenceUnit: persistence] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: message, for columns: [org.hibernate.mapping.Column(comments)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:349)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:322)
at org.hibernate.mapping.Property.isValid(Property.java:241)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:496)
at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1360)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1851)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
... 75 more
Comment.java:
@Entity
public class Comment {
@Id @GeneratedValue
private Long id;
private String descricao;
public Comment(){}
public Comment(String descricao){
this.descricao=descricao;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final Comment other = (Comment) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
信息:
@Entity
public class Message {
@Id
@GeneratedValue
private Long id;
private String nome;
private String cor;
private List<Comment> comments;
@OneToMany
public List<Comentario> getComments() {
return comments;
}
public void setComments(List<Comment> comments) {
this.comments = comments;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getNome() {
return this.nome;
}
public void setCor(String cor) {
this.cor = cor;
}
public String getCor() {
return this.cor;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final Message other = (Message ) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
@实体
公共类消息{
@身份证
@生成值
私人长id;
私有字符串名称;
私有字符串cor;
私人名单评论;
@独身癖
公共列表getComments(){
返回评论;
}
公共注释(列出注释){
this.comments=注释;
}
公共无效集合名称(字符串名称){
this.nome=nome;
}
公共字符串getNome(){
归还这个.nome;
}
公共无效设置目录(字符串目录){
this.cor=cor;
}
公共字符串getCor(){
归还这个.cor;
}
公共无效集合id(长id){
this.id=id;
}
公共长getId(){
返回此.id;
}
@凌驾
公共int hashCode(){
最终整数素数=31;
int结果=1;
result=prime*result+((id==null)?0:id.hashCode();
返回结果;
}
@凌驾
公共布尔等于(对象obj){
if(this==obj)
返回true;
if(obj==null)
返回false;
如果(getClass()!=obj.getClass())
返回false;
最终消息其他=(消息)obj;
if(id==null){
if(other.id!=null)
返回false;
}如果(!id.equals(other.id))
返回false;
返回true;
}
}
检查为什么您的列表有不同的类型?在你的getter上有Comentario,在setter上有Comment。检查一下为什么你的列表有不同的类型?在你的起跑手上你有Comentario,在二传手上你有评论。