首先介绍几个错误
org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [cn.wuchuanlong.oa.domain.Depart]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [cn.wuchuanlong.oa.domain.Depart] at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:630) at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424) at org
老是这样的错误,总结原因如下:
1、depart中涉及到的一些属性spring没有给其注入
2、或者是说要插入的表和数据库中的关键字重名
org.hibernate.exception.SQLGrammarException:could not insert
可能是由于表名和数据库中的关键字重名
2、表中的数据插不进去:看看是否为save所在的方法开启了事务