日期:2014-05-16  浏览次数:20465 次

自己遇到的Could not execute JDBC batch update的问题
问题:
2010-06-25 11:48:54,832 ERROR (JDBCExceptionReporter.java:72) - Data truncation: Column set to default value; NULL supplied to NOT NULL column 'dept_id' at row 1
2010-06-25 11:48:54,846 ERROR (AbstractFlushingEventListener.java:300) - Could not synchronize database state with session
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.DataException: Could not execute JDBC batch update

情况:
当时我只是想更新部门(dept)信息,而其跟员工(employee)有一对多的关系。跟分公司(branch)有对应关系,但是没有实体的关系。在我对部门修改分公司名称的时候报了以上的错误。

解决方式:
这种问题别人也有说到有几种解决方式
1.自动生成的*.hbm.xml文件中Class中自带的catlog属性要去掉。
2.*.hbm.xml文件中不能出现关键字,如ID,date。
3.在我这里:
Dept.hbm.xml文件有一处
<set name="employees">
            <key >
                <column name="DEPT_ID" length="50" />
            </key>
                <one-to-many class="com.vo.Employee" />
</set>
加粗的地方在配置多方的时候配错了。开始配成了Dept。