2012-02-02 4 views
4

I가 최대 절전 모드에서 다음 개체 :SQLStateConverter.handledNonSpecificException 최대 절전 모드

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

나 최대 절전 모드의이 메서드를 호출 :

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) 
} 

: 나는 다음과 같은 예외가

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

이 간단한 코드를 사용해 보았습니다.

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

그리고 제대로 작동합니다.

무엇이 문제입니까?

Date의 유형은 두 경우 모두 java.util.Date입니다.

편집을 할

나는 그것을 더 이상 디버깅 및 예외는 것을보고 :이

Bad format for DATE '517' in column 2. 

날짜 : 1985년 5월 17일

+0

데이터베이스의 날짜 컬럼의 데이터 유형은 무엇이며 어떤 RDBMS입니까? – centic

+0

@centic 유형은 날짜 및 데이터입니다. RDMBS는 무엇을 의미합니까? 나는 mysql이다. – Dejell

답변

4

아주 아주 바보 문제가.

최대 절전 모드의 필드 이름은 birthday이고 db는 registration_date입니다. DB에서

birthday

1

당신은 따라서 당신은 DB 컬럼의 이름을 변경할 필요가 없습니다

@Column(name="registration_date") 
private Date birthday; 

JPA

의 최대 절전 모드의 구현에 따라 오는 표기법을 사용할 수 있습니다 .. int로 필드했다.

건배