数据库为mysql
hibernate3.0
连接驱动为3.1.13
数据库中的时间字段类型为timestamp,
实体类中属性类型为Date
映射如下
<property name="reserveDate" type="timestamp">
<column name="reserveDate" />
</property>
或者
<property name="reserveDate" type="java.util.Date">
<column name="reserveDate" />
</property>
在保存的时候都只保存了年月日,没有时分秒;求指教!
个人觉得你可以这样
1 直接使用sql语句insert,看是不是有时分秒
2 使用纯jdbc来insert
这2步下来之后你应该就会知道是不是hibernate配置文件问题了,解决问题有时候需要一点一点排除,并不一定是你映射的问题。
new Timestamp((new java.util.Date()).getTime())