com.vaadin.data.Property$ConversionException:
java.lang.NoSuchMethodException:
java.sql.Date.(java.lang.String)
对此有什么解决方法......这是我的POJO课程
package your.intermedix.domain;
import java.io.Serializable;
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Contact POJO.
*
* @hibernate.class table = "contact"
* @hibernate.cache usage = "read-write"
*/
public class Contact implements Serializable {
private static final long serialVersionUID = -8361595011677919387L;
/**
*
* @hibernate.id generator-class = "increment"
* column = "clientid"
*/
private Long id = null;
/**
*
* @hibernate.property column = "name"
* length = "100"
* not-null = "true"
*/
private String name = null;
/**
*
* @hibernate.property column = "email"
* length = "100"
* not-null = "true"
*/
private String email;
/**
*
* @hibernate.property column = "lastname"
* length = "100"
* not-null = "true"
*/
private String lastname;
/**
*
* @hibernate.property column = "designation"
* length = "100"
* not-null = "true"
*/
private String designation;
/**
*
* @hibernate.property column = "date"
* length = "100"
* not-null = "true"
*/
private Date date;
/**
*
* @hibernate.property column = "comments"
* length = "100"
* not-null = "true"
*/
private String comments;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDesignation(){
return designation;
}
public void setDesignation(String designation){
this.designation = designation;
}
public String getEmail(){
return email;
}
public void setEmail(String email){
this.email = email;
}
public String getLastname(){
return lastname;
}
public void setLastname(String lastname){
this.lastname= lastname;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public Date getDate(){
return date;
}
public void setDate(Date date){
this.date = date;
}
public String getComments(){
return comments;
}
public void setComments(String name){
this.comments = comments;
}
public String toString()
{
return "designation = '" + designation + "',email='"+ email +"', lastname='"+ lastname +"', name = '" + name + "', date='" + date +"', comments='" + comments +"'";
}
}
答案 0 :(得分:4)
你得到解释的每一个例外。 java.sql.Date没有带字符串的构造函数。这就是你得到这个异常的原因。 java.util.Date有这样的构造函数,不推荐使用它。您可以使用SimpleDateFormat类将String转换为Date对象..
答案 1 :(得分:3)
如何不使用java.sql包中的Date,而是使用java.util?
答案 2 :(得分:1)
date
字段声明为
/**
*
* @hibernate.property column = "date"
* length = "100"
* not-null = "true"
*/
private Date date;
length = 100
的约会?你能尝试改变这个吗?