Hi , i am suman.
i have a problem with hibernate...when i am executing the getHibernateTemplate().update(object); the following error coming.
Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
the scenario of exception coming is: 1)i have a page in that page had one bulk field check box,when i am check that bulk check box i added the deal with four child records with parent record id. 2)second in that page i uncheck the bulk deal then immediatly i want to delete the child records from my database so that i wrote that code it was successfully deleted child records from the database. 3)now again i am check that bulk check box and i am adding four child records and updating the deal.......when the compilation comes to the getHibernateTemplate().update(object);
the following error coming: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
the methods i wrote for the deletion of child records...........as follows:
DaoImpl class: public GroupDeal removeDealSlabs(GroupDeal groupDeal)throws Exception{ if(groupDeal!=null){ groupDeal= (GroupDeal) getHibernateTemplate().get(GroupDeal.class, groupDeal.getGroupDealId()); GroupDealSlabs c = null; while( groupDeal.getGroupDealSlabses().iterator().hasNext()){ c = (GroupDealSlabs) groupDeal.getGroupDealSlabses().iterator().next(); getHibernateTemplate().delete(c); groupDeal.getGroupDealSlabses().remove(c); } groupDeal.getGroupDealSlabses().clear(); getHibernateTemplate().evict(c); getHibernateTemplate().evict(groupDeal); getHibernateTemplate().flush(); } return groupDeal; }
public boolean updateGroupDeal(final GroupDeal groupDeal) throws Exception{ boolean result = false; if (getHibernateTemplate() != null) { getHibernateTemplate().update(groupDeal); Here i am getting the exception as the scenario above i mentioned the third step getHibernateTemplate().flush(); result = true; } return result; }
hbm file content: <set name="groupDealSlabses" inverse="true" lazy="false" order-by="Group_Deal_Slab_Price" cascade="all-delete-orphan"> <key> <column name="Group_Deal_ID" not-null="true" /> </key>
<one-to-many class="com.yatra.groupdeals.dao.model.GroupDealSlabs" /> </set>
These my problem sir.....i need some help from you,i have seen so many sites for avoid these exception but i didnt get a solution for that......
|