I try to save an object but Hibernate try to update a field on a one-to-one association, therefore I have an exception because the data doesn't exist.
Code:
Hibernate: insert into SIREN (APPARTENANCE_DGE, PK_NUM_SIREN) values (?, ?)
Hibernate: insert into ADHERENT (ADR_MAIL, CIVILITE, DATE_CREATION, DATE_FIN_VALIDITE, NOM, NUM_TEL, PRENOM, ID_RENOUVELLEMENT, PK_NUM_ADHERENT) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into TRACE (DATE_EVT, DATE_PURGE_EVT, DETAIL_EVT_2, DETAIL_EVT_3, DETAIL_EVT_1, ID_USAGER, ESERVICE, ID_AGENT, ID_APPLICATIF, LIB_SIREN_USAGER, LISTE_IMPOT, NOM_AGENT, NOM_USAGER, NOM_SERVICE, NUM_CERTIFICAT_USAGER, NUM_FORMULAIRE, NUM_SAGES, NUM_SAGES_AGENT, NUM_SIREN_USAGER, PRENOM_AGENT, PRENOM_USAGER, ROLE_USAGER, SIREN_ACTION, TYPE_EVT, PK_TRACE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update SIREN_APPARTENANCE set SIREN=?, ETRANGER=? where PK_NUM_ADHERENT=?
- 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.update(EntityPersister.java:722)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:675)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:51)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2362)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2317)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2258)
at fr.gouv.finances.dgi.opale.technique.util.SessionHibernate.endTransaction(SessionHibernate.java:116)
at fr.gouv.finances.dgi.opale.inscription.services.AdherentServiceImpl.inscrireAdherent(AdherentServiceImpl.java:121)
at TestCnxDB.main(TestCnxDB.java:174)
- Erreur hibernate
with the following mapping :
Code:
<hibernate-mapping>
<class name="fr.gouv.finances.dgi.opale.commun.transverse.persistent.AdherentPersistent" table="ADHERENT">
<id name="numAdherent" column="PK_NUM_ADHERENT">
<generator class="assigned"/>
</id>
<property name="adrMailAdherent" column="ADR_MAIL" not-null="true"/>
<property name="civiliteAdherent" column="CIVILITE" not-null="true"/>
<property name="dateCreationAdherent" column="DATE_CREATION" not-null="true" type="date"/>
<property name="dateFinValiditeIdRenouvellement" column="DATE_FIN_VALIDITE" type="date" not-null="false"/>
<property name="nomAdherent" column="NOM" not-null="true"/>
<property name="numTelAdherent" column="NUM_TEL" not-null="false"/>
<property name="prenomAdherent" column="PRENOM" not-null="true"/>
<one-to-one name="sirenAppartenance" class="fr.gouv.finances.dgi.opale.commun.transverse.persistent.SirenAppartenancePersistent" cascade="save-update" constrained="false"/>
<property name="idRenouvellement" column="ID_RENOUVELLEMENT" not-null="false"/>
<one-to-one name="adresse" class="fr.gouv.finances.dgi.opale.commun.transverse.persistent.AdressePersistent" cascade="save-update" constrained="false"/>
<one-to-one name="certificat" class="fr.gouv.finances.dgi.opale.commun.transverse.persistent.CertificatPersistent" cascade="save-update" constrained="false"/>
<set name="listeReponseQuestionConfianceAdherent" lazy="true" inverse="true" cascade="save-update">
<key column="FK_NUM_ADHERENT"/>
<one-to-many class="fr.gouv.finances.dgi.opale.commun.transverse.persistent.ReponseQuestionConfianceAdherentPersistent"/>
</set>
</class>
</hibernate-mapping>