resoudre exception StaleStateException
Bonjour ,
J'esaye de faire un update mais je recupere cette exception
Code:
1 2
|
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1 |
Si vous pouvez me donnez un coup de main, j'ai essayé plein de choses mais rien ne marche
voici le fichier de mapping
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.eurecia.backoffice.ListValue" table="LIST_VALUE_EA">
<composite-id name="id" class="com.eurecia.backoffice.ListValueId" >
<key-property name="type" type="java.lang.String">
<column name="TYPE_LIST_VALUE" scale="50" precision="0" not-null="true" sql-type="varchar" />
</key-property>
<key-property name="value" type="java.lang.String">
<column name="ID_VALUE" scale="50" precision="0" not-null="true" sql-type="varchar" />
</key-property>
<key-property name="idCompany" type="java.lang.String">
<column name="ID_COMPANY" scale="50" precision="0" not-null="true" sql-type="varchar" />
</key-property>
</composite-id>
<property name="num" type="java.lang.Integer">
<column name="NUM_VALUE" scale="4" precision="0" not-null="true" sql-type="decimal" />
</property>
<property name="default" type="java.lang.Boolean">
<column name="DEFAULT_VALUE" scale="1" precision="0" not-null="true" sql-type="decimal" />
</property>
<property name="userCreate" type="java.lang.String">
<column name="USER_CREATE" scale="255" precision="0" not-null="true" sql-type="varchar" />
</property>
<property name="dateCreate" type="java.util.Date">
<column name="DATE_CREATE" scale="19" precision="0" not-null="true" sql-type="datetime" />
</property>
<property name="userUpdate" type="java.lang.String">
<column name="USER_UPDATE" scale="255" precision="0" not-null="false" sql-type="varchar" />
</property>
<property name="dateUpdate" type="java.util.Date">
<column name="DATE_UPDATE" scale="19" precision="0" not-null="false" sql-type="datetime" />
</property>
<map name="descr" table="LIST_VALUE_DESCR_EA" cascade="all" lazy="false">
<key>
<column name="TYPE_LIST_VALUE" scale="50" precision="0" not-null="true" sql-type="varchar" />
<column name="ID_VALUE" scale="50" precision="0" not-null="true" sql-type="varchar" />
<column name="ID_COMPANY" scale="50" precision="0" not-null="true" sql-type="varchar" />
</key>
<map-key column="LOCALE" type="java.lang.String" length="10"/>
<composite-element class="com.eurecia.backoffice.Description">
<property name="shortDescription" type="java.lang.String">
<column name="SDESCR_VALUE" scale="50" precision="0" not-null="true" sql-type="varchar" />
</property>
<property name="longDescription" type="java.lang.String">
<column name="LDESCR_VALUE" scale="2000" precision="0" not-null="false" sql-type="varchar" />
</property>
<property name="comment" type="java.lang.String">
<column name="COMMENT_VALUE" scale="8000" precision="0" not-null="false" sql-type="varchar" />
</property>
</composite-element>
</map>
</class>
</hibernate-mapping> |
voici la fonction update
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
public void update(PersistentObject object) throws PersistanceException, DuplicateEntryException {
Session session = null ;
Transaction transaction = null;
try {
session = HibernateSessionFactory.currentSession();
transaction = session.beginTransaction();
session.update(object) ;
transaction.commit();
} catch (ConstraintViolationException cve) {
rollback(transaction);
// duplicate item
if (cve.getErrorCode()==1062)
throw new DuplicateEntryException(cve.getMessage());
// persistance error
throw new PersistanceException(cve.getMessage(),cve);
} catch (Exception he) {
rollback(transaction);
throw new PersistanceException(he.getMessage(),he);
}
finally
{
try {HibernateSessionFactory.closeSession(); } catch (Exception he) {}
}
} |
Je prends toute sorte de suggestions.
Et s'il manque des infos n'hesitez pas.
Merci.