hibernate 查询的时候正常就是save的时候提示错误数据库mysql Batch update returned unexpected
错误提示Exceptioninthread"main"org.hibernate.StaleStateException:Batchupdatereturnedunexp...
错误提示
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.free.dome01.PersonOperate.insert(PersonOperate.java:41)
at com.free.dome01.TestPO.main(TestPO.java:21)
数据库
CREATE TABLE person
(
id varchar(32) not null primary key ,
name varchar(20) not null ,
password varchar(20) not null ,
sex varchar(2) ,
email varchar(30)
) ;
Person.hbm.xml
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Thu Nov 09 16:06:12 CST 2006 -->
<hibernate-mapping package="com.free.dome01">
<class name="Person" table="PERSON">
<id name="id" column="ID" type="string">
<generator class="assigned"/>
</id>
<property name="name" column="NAME" type="string" not-null="true" />
<property name="password" column="PASSWORD" type="string" not-null="true" />
<property name="sex" column="SEX" type="string" />
<property name="email" column="EMAIL" type="string" />
</class>
</hibernate-mapping>
http://topic.csdn.net/u/20080601/11/810a64b4-aac7-40c1-922e-c9894c37264e.html 代码在这 这里放不下 展开
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.free.dome01.PersonOperate.insert(PersonOperate.java:41)
at com.free.dome01.TestPO.main(TestPO.java:21)
数据库
CREATE TABLE person
(
id varchar(32) not null primary key ,
name varchar(20) not null ,
password varchar(20) not null ,
sex varchar(2) ,
email varchar(30)
) ;
Person.hbm.xml
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Thu Nov 09 16:06:12 CST 2006 -->
<hibernate-mapping package="com.free.dome01">
<class name="Person" table="PERSON">
<id name="id" column="ID" type="string">
<generator class="assigned"/>
</id>
<property name="name" column="NAME" type="string" not-null="true" />
<property name="password" column="PASSWORD" type="string" not-null="true" />
<property name="sex" column="SEX" type="string" />
<property name="email" column="EMAIL" type="string" />
</class>
</hibernate-mapping>
http://topic.csdn.net/u/20080601/11/810a64b4-aac7-40c1-922e-c9894c37264e.html 代码在这 这里放不下 展开
展开全部
有无主键.其实hibernate是以对象的方式更新的,如果不想这么用,就自己在dao类中写方法更新!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned
批量更新出错
批量更新出错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的代码呢?
这应该是你的批量更新数据的代码有问题
这应该是你的批量更新数据的代码有问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询