Hibernate继承映射的问题:一个类一个表
Exceptioninthread"main"org.hibernate.StaleStateException:Batchupdatereturnedunexpecte...
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.xie.ManyToOne.add(ManyToOne.java:121)
at com.xie.ManyToOne.main(ManyToOne.java:22)
hbm.xml配置如下:
<hibernate-mapping package="com.xie.domain">
<class name="Employee" >
<id name="id">
<generator class="hilo"/>
</id>
<property name="name" unique="true"/>
<many-to-one name="depart" column="depart_id"/>
<union-subclass name="Skiller" table="skiller">
<property name="skill"/>
</union-subclass>
<union-subclass name="Sales" table="sales">
<property name="sell"/>
</union-subclass>
</class>
</hibernate-mapping>
请问问题出在哪儿?? 展开
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.xie.ManyToOne.add(ManyToOne.java:121)
at com.xie.ManyToOne.main(ManyToOne.java:22)
hbm.xml配置如下:
<hibernate-mapping package="com.xie.domain">
<class name="Employee" >
<id name="id">
<generator class="hilo"/>
</id>
<property name="name" unique="true"/>
<many-to-one name="depart" column="depart_id"/>
<union-subclass name="Skiller" table="skiller">
<property name="skill"/>
</union-subclass>
<union-subclass name="Sales" table="sales">
<property name="sell"/>
</union-subclass>
</class>
</hibernate-mapping>
请问问题出在哪儿?? 展开
4个回答
展开全部
我是学struts2的,对于struts1不知道适不适用,我先说说吧,你觉得好就加分吧。纯手打
forward 是一个跳转的标签,其中name是在Action中取得的,就是说Action里面根据你需要的转向而发出的一个gdfg字符串。我举下例子:
好像这样我有一个登录方法。如果登录成功就返回一个success字符串,else,返回一个error字符串,然后sturts-config.xml根据你的name转到相应的 path 页面
<forward name="success" path="/jsp/ko_wake.jsp" />
<forward name="error" path="/jsp/error.jsp" />
不知道这样说你能明白不
forward 是一个跳转的标签,其中name是在Action中取得的,就是说Action里面根据你需要的转向而发出的一个gdfg字符串。我举下例子:
好像这样我有一个登录方法。如果登录成功就返回一个success字符串,else,返回一个error字符串,然后sturts-config.xml根据你的name转到相应的 path 页面
<forward name="success" path="/jsp/ko_wake.jsp" />
<forward name="error" path="/jsp/error.jsp" />
不知道这样说你能明白不
展开全部
<generator class="hilo"/>
你的Hilo是人为制定id,如果不指定就出错误了
你的Hilo是人为制定id,如果不指定就出错误了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有时候数据库出现脏数据也会出现这种错误,你看看会不会有脏数据。就是你关联的那个id在那个表中对应此id的数据已不存在。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这应该是你用UPDATE方法是希望更新,但却没更新成功,应该和配置无关
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询