在web开发中hibernate3插入数据库日期不一致的问题解决方法

来源:互联网 发布:塞上牛羊空许约 知乎 编辑:程序博客网 时间:2024/06/16 07:30

今天在写一个web项目时抛出异常

 nested exception is org.hibernate.exception.DataException: could not insert: [firstapp.order.vo.Order]

可见是date出错 后台我用的java.util.Date的时间格式,按道理应该是没有问题的,后来细想了一下相关的hibernate.hbm.xml

是不是有问题 果然我在这里    <property name="ordertime"></property>起初是没有加type的后来更改问题也就没了

如下

 <hibernate-mapping>
         <class name="firstapp.order.vo.Order" table="xxx">
             <id name="oid">
                 <generator class="native"></generator>
             </id>
             <property name="total"></property>
             <property name="ordertime" type="date"></property>
             <property name="state"></property>
             <property name="name"></property>

         </class>
    </hibernate-mapping>

阅读全文
1 0