I have a small program, which try to update an informix database based on given parameters. First I delete the original records from db, then insert the new one. The problem occurs, and I searched the forum and tried all of the solutions it mentions, but my problem still there, which is:
Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL update or deletion failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.java:582)
at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2266)
at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1738)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1499)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
at MsgReciver.saveObj(MsgReciver.java:252)
at MsgReciver.readObject(MsgReciver.java:126)
at MsgReciver.main(MsgReciver.java:40)
My code is simple:
Code:
session.delete(query, new Object[] { pk1, pk2 }, new Type[] {Hibernate.STRING, Hibernate.STRING });
session.flush();
session.save(obj);
and all of my mapping files are like this one:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="other"
table="t_other"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="p_no"
column="p_no"
type="string"
unsaved-value="null"
>
<generator class="assigned">
</generator>
</id>
<property
name="act_pre"
type="double"
update="true"
insert="true"
column="act_pre"
/>
<property
name="adjratio"
type="double"
update="true"
insert="true"
column="adjratio"
/>
<property
name="ayear_pre"
type="double"
update="true"
insert="true"
column="ayear_pre"
/>
<property
name="bas_pre"
type="double"
update="true"
insert="true"
column="bas_pre"
/>
<property
name="beadj"
type="double"
update="true"
insert="true"
column="beadj"
/>
<property
name="canprm"
type="char"
update="true"
insert="true"
column="canprm"
/>
<property
name="chxcsh"
type="short"
update="true"
insert="true"
column="chxcsh"
/>
<property
name="edrno"
type="string"
update="true"
insert="true"
column="edrno"
/>
<property
name="fgs"
type="string"
update="true"
insert="true"
column="fgs"
/>
<property
name="fl"
type="double"
update="true"
insert="true"
column="fl"
/>
<property
name="ispar"
type="short"
update="true"
insert="true"
column="ispar"
/>
<property
name="last_t_date"
type="date"
update="true"
insert="true"
column="last_t_date"
/>
<property
name="last_u_date"
type="date"
update="true"
insert="true"
column="last_u_date"
/>
<property
name="max_xe"
type="double"
update="true"
insert="true"
column="max_xe"
/>
<property
name="mp"
type="double"
update="true"
insert="true"
column="mp"
/>
<property
name="oldzxdm"
type="string"
update="true"
insert="true"
column="oldzxdm"
/>
<property
name="otherprm"
type="double"
update="true"
insert="true"
column="otherprm"
/>
<property
name="pchje"
type="double"
update="true"
insert="true"
column="pchje"
/>
<property
name="plc_no"
type="string"
update="true"
insert="true"
column="plc_no"
/>
<property
name="pre_rate"
type="double"
update="true"
insert="true"
column="pre_rate"
/>
<property
name="rz"
type="short"
update="true"
insert="true"
column="rz"
/>
<property
name="safeprm"
type="double"
update="true"
insert="true"
column="safeprm"
/>
<property
name="safeyear"
type="short"
update="true"
insert="true"
column="safeyear"
/>
<property
name="senum"
type="short"
update="true"
insert="true"
column="senum"
/>
<property
name="vageadj"
type="double"
update="true"
insert="true"
column="vageadj"
/>
<property
name="vehno"
type="short"
update="true"
insert="true"
column="vehno"
/>
<property
name="xzhdm"
type="string"
update="true"
insert="true"
column="xzhdm"
/>
<property
name="year_pre"
type="double"
update="true"
insert="true"
column="year_pre"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-other.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Please help me! [/code]