hibernate的Could not execute JDBC batch update错误原因及处理
来源:互联网 发布:剑灵灵女萌妹子数据 编辑:程序博客网 时间:2024/05/21 10:13
今天用hibernate做系统的时候,出现了Could not execute JDBC batch update错误,现在已经解决。
先说说我的代码:
这是角色表对应的配置文件,当我在角色管理列表的jsp页面里删除选中的角色信息,就报了上面的错误。
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.cms.po.Trole" table="trole">
<id name="roleId" type="integer">
<column name="roleId" />
<generator class="native" />
</id>
<property name="roleName" type="string">
<column name="roleName" length="50" />
</property>
<property name="isDel" type="string">
<column name="isDel" length="2" />
</property>
<property name="roleDescribe" type="string">
<column name="roleDescribe" length="500" />
</property>
<property name="createTime" type="string">
<column name="createTime" length="32" />
</property>
<!-- 创建的用户id 一对一 -->
<many-to-one
name="tsysuser"
column="userId"
unique="true"
class="com.cms.po.Tsysuser" lazy="false"/>
</class>
</hibernate-mapping>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.cms.po.Trole" table="trole">
<id name="roleId" type="integer">
<column name="roleId" />
<generator class="native" />
</id>
<property name="roleName" type="string">
<column name="roleName" length="50" />
</property>
<property name="isDel" type="string">
<column name="isDel" length="2" />
</property>
<property name="roleDescribe" type="string">
<column name="roleDescribe" length="500" />
</property>
<property name="createTime" type="string">
<column name="createTime" length="32" />
</property>
<!-- 创建的用户id 一对一 -->
<many-to-one
name="tsysuser"
column="userId"
unique="true"
class="com.cms.po.Tsysuser" lazy="false"/>
</class>
</hibernate-mapping>
每创建角色,都对应着创建人的id,但是我为了测试省事,直接把数据插进表里,并且没有在表里插入创建人的userId,再看看代码:
/** *//**
* 批量删除角色
*/
public boolean deleteRoles(String roleids) throws Exception ...{
String[] roleidArray = roleids.split(",");
for(int i=0; i<roleidArray.length; i++)...{
Trole trole = (Trole)this.getHibernateTemplate().get(Trole.class,new Integer(roleidArray[i]));
trole.setIsDel("1");
this.getHibernateTemplate().saveOrUpdate(trole);
}
return true;
}
* 批量删除角色
*/
public boolean deleteRoles(String roleids) throws Exception ...{
String[] roleidArray = roleids.split(",");
for(int i=0; i<roleidArray.length; i++)...{
Trole trole = (Trole)this.getHibernateTemplate().get(Trole.class,new Integer(roleidArray[i]));
trole.setIsDel("1");
this.getHibernateTemplate().saveOrUpdate(trole);
}
return true;
}
没有什么问题,但是却报了Could not execute JDBC batch update的错,主要是配置文件设置了关联,数据却没有关联造成的,只要数据正确就没有问题。
另外,造成这个原因的还可能是数据库的驱动jar包不支持。
还有就是csdn的dizhang的专栏提到的下面问题引起的:
1.因为Hibernate Tools(或者Eclipse本身的Database Explorer)生成*.hbn.xml工具中包含有catalog="***"(*表示数据库名称)这样的属性,将该属性删除就可以了
2.估计是你的列名里面有关键字的原因吧,命名列的时候不要单独使用date,ID...这种关键字
Hibernate查询时候的问题。
莫名其妙地报如下的错误,
org.hibernate.exception.GenericJDBCException: could not execute query
- hibernate的Could not execute JDBC batch update错误原因及处理
- hibernate的Could not execute JDBC batch update错误原因及处理
- hibernate的Could not execute JDBC batch update错误原因及处理
- hibernate的Could not execute JDBC batch update错误原因及处理
- hibernate的Could not execute JDBC batch update错误原因及处理
- hibernate错误:IllegalArgumentException以及Could not execute JDBC batch update
- Hibernate数据关联映射出现Could not execute JDBC batch update的异常处理
- 用Struts+DAO+Hibernate+MySql写的程序发生:org.hibernate.exception.DataException:Could not execute JDBC batch update的错误原因
- Could not execute JDBC batch update 错误 原因 oracle数据 你存入数据过大
- Hibernate抛异常Could not execute JDBC batch update
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
- org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- 编程员该何去何从
- 使用MDX实现多维关联分析
- Jdk_Tomcat配置
- string与stringbuffer的区别
- 一个sqlserver中用到的函数,用来取拼音
- hibernate的Could not execute JDBC batch update错误原因及处理
- 彻底搞清楚librarycachelock的成因和解决方法(三)
- 彻底搞清楚librarycachelock的成因和解决方法(二)
- java.sql.SQLException: Before start of result set
- .net 2.0(c#)下简单的FTP应用程序
- 基础java容易忽略的地方
- 彻底搞清楚librarycachelock的成因和解决方法(一)
- 给新入职朋友的一点分享
- PowerDesign9.5+中的GTL解决大问题