由hibernate 的逆向工具从数据库表生成的*.hbm.xml ,对于数据库的date类型生成如下:
       <property name = "crttime" type= "date">
            <column name = "CRTTIME" length = "7"  />
        </property >
 
程序中的类型:
private Date crttime ;
但通过程序setCrttime(new Date()) 的时候,插入到数据库的日期只到天,没有小时以后的数据。
 
网上查了一下,有的说可以修改type类型为 java.util.Date, 但实验发现hibernate不能识别此类型,修改为timestamp则可以。
 
如下是最终修改:
        <property name ="crttime" type="timestamp">
            <column name ="CRTTIME"   />
        </property >
 
我把length = "7" 也去掉了
 

相关文章:

  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-09
  • 2021-04-26
  • 2021-06-19
  • 2022-12-23
  • 2022-02-18
  • 2021-06-16
  • 2022-02-08
相关资源
相似解决方案