I have the following object in Hibernate:
@Entity public class Contact implements Serializable { private static final long serialVersionUID = 1L; @Temporal(TemporalType.DATE) private Date birthday; }
When I call this sleep mode method:
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 it works great.
What is the problem?
The Date type is java.util.Date in both cases.
EDITED
I debugged it more and saw that exception:
Bad format for DATE '517' in column 2.
Date: 1985-05-17
source share