Categories
hibernate java mysql sql

SQLStateConverter.handledNonSpecificException hibernate

I have the following entity in Hibernate:

@Entity
public class Contact implements Serializable {
private static final long serialVersionUID = 1L;
@Temporal(TemporalType.DATE)
private Date birthday;
}

When I call this method of hibernate:

public Object get(Class entityClass, Serializable id) throws HibernateException {
return get( entityClass.getName(), id );
}

I get the following exception:

org.hibernate.exception.GenericJDBCException: could not load an entity: [com.mycompany.model.Contact#3]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
}

I tried this simple code:

Statement st = conn.createStatement();
ResultSet res = st.executeQuery("select registration_date from contact where contact_id=3");
Date i = res.getDate(1);

And this works fine.

What is the problem?

The type of Date is java.util.Date in both cases.

EDITED

I debugged it more, and saw that the exception is:

Bad format for DATE '517' in column 2.

The date there is: 1985-05-17