MySQL / JDBC / Hibernate第19列中DATE'91'的格式错误

时间:2017-09-28 10:24:28

标签: mysql hibernate

模型中的

使用日期作为类型

@Column(name="birthdate")
private Date birtdate;

我在春季启动应用程序中的模型用户中使用日期类型时遇到以下异常

Hibernate: select user0_.user_id as user_id1_1_, user0_.address as address2_1_, user0_.alt_isd as alt_isd3_1_, user0_.alt_no as alt_no4_1_, user0_.approved as approved5_1_, user0_.birthdate as birthdat6_1_, user0_.blood_group as blood_gr7_1_, user0_.ckey as ckey8_1_, user0_.comp_name as comp_nam9_1_, user0_.created_date as created10_1_, user0_.ctime as ctime11_1_, user0_.driverunderuser as driveru12_1_, user0_.email as email13_1_, user0_.emergencycontact0 as emergen14_1_, user0_.emergencycontact1 as emergen15_1_, user0_.emergencycontact2 as emergen16_1_, user0_.image as image17_1_, user0_.interval_time as interva18_1_, user0_.isd_code as isd_cod19_1_, user0_.last_name as last_na20_1_, user0_.driver_license_no as driver_21_1_, user0_.license_expiry_date as license22_1_, user0_.mobile as mobile23_1_, user0_.modified_date as modifie24_1_, user0_.name as name25_1_, user0_.password as passwor26_1_, user0_.status as status27_1_, user0_.user_confirmation as user_co28_1_, user0_.user_type as user_ty29_1_, user0_.user_name as user_na30_1_ from tbl_user user0_ where user0_.user_name=?
    2017-09-28 15:43:41.707  WARN 6844 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: S1009
    2017-09-28 15:43:41.707 ERROR 6844 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : `Bad format for DATE '91' in column 19.`
    2017-09-28 15:43:41.719 ERROR 6844 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query] with root cause

    java.sql.SQLException: Bad format for DATE '91' in column 19.
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.44.jar:5.1.44]

1 个答案:

答案 0 :(得分:0)

请尝试

@Column(name="birthdate")
@Temporal(TemporalType.DATE)
private Date birtdate;

请参阅What is the use of the @Temporal annotation in Hibernate?