ERROR: HHH000091: Expected type: java.sql.Timestamp, actual value: java.lang.Integer

在将MySql的数据对应到Java的实体类的时候, 遇到了错误

关键点: 

 Hibernate从mysql数据库查出来的Timestamp类型的数据, 会被Hibernate(或者是数据库连接池Druid)自动转换为了Integer数据类型

所以就应该把Entity实体类中的Timestamp的数据类型修改为Integer类型, 然后问题就得到了解决

结果如下: 能正常运行了

---------划重点------------------

后来又发现这个问题原来真正的原因在这里!!!!

    在这个文件的com/bj186/crm/entity/User.hbm.xml配置属性中, 不小心把数据返回类型写成 type="java.lang.Integer" 了,

    难怪数据库中查出来的时候回自动转换为Integer类

<property name="birthday" column="birthday" type="java.lang.Integer"> </property>
因此把这段代码修改为如下
<property name="birthday" column="birthday" type="java.sql.Timestamp"> </property>
问题解决!
 
原文地址:https://www.cnblogs.com/zjulanjian/p/10938541.html