Problème org.hibernate.StaleStateException entité maitre détail
Bonjour,
J'ai une entité maitre et une autre détail que j'ai créé avec hibernate.
J'ai voulu faire un delete sur le détail puis le maitre puis commit dans une classe java.
J'ai rencontré une exceptionorg.hibernate.StaleStateException après le commit, comme si le traitement est en train de faire un update sur la table maitre et ne trouve pas l'enregistrement puisqu'il a été suppimé.
Le problème est que je n'ai aucun update dans mon programme java.
voici l'erreur :
Citation:
2020-09-09 10:21:44 [ERROR] HHH000315: Exception executing batch [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]
2020-09-09 10:21:44 [ERROR] HHH000315: Exception executing batch [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]
2020-09-09 10:21:44 [ERROR] MSG|Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
2020-09-09 10:21:44 [ERROR] MSG|exception
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Voici l'entité maitre Tclient:
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| package com.entities.pro.commun;
// Generated by Hibernate Tools 3.2.4.GA
import static javax.persistence.GenerationType.SEQUENCE;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* Tclient generated by hbm2java
*/
@Entity
@Table(name = "Tclient")
public class Tclient implements java.io.Serializable {
private String codCategclient;
private String codCommuninsee;
private String codDeptnais;
private String codFormjur;
private BigDecimal codTiers;
private Set<Tadresse> Tadresses = new HashSet<Tadresse>(0);
public Tclient() {
}
public Tclient(final String codCategclient, final String codCommuninsee, final String codDeptnais, final BigDecimal codTiers, final String codFormjur, final Set<Tadresse> Tadresses) {
super();
this.codCategclient = codCategclient;
this.codCommuninsee = codCommuninsee;
this.codDeptnais = codDeptnais;
this.codFormjur = codFormjur;
Tadresses = Tadresses;
}
@Column(name = "COD_CATEGCLIENT", length = 3)
public String getCodCategclient() {
return this.codCategclient;
}
@Column(name = "COD_COMMUNINSEE", length = 5)
public String getCodCommuninsee() {
return this.codCommuninsee;
}
@Column(name = "COD_DEPTNAIS", length = 3)
public String getCodDeptnais() {
return this.codDeptnais;
}
@Column(name = "COD_FORMJUR", length = 4)
public String getCodFormjur() {
return this.codFormjur;
}
@SequenceGenerator(name = "generator", sequenceName = "TclientSEQ")
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "generator")
@Column(name = "COD_TIERS", unique = true, nullable = false, precision = 0)
public BigDecimal getCodTiers() {
return this.codTiers;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "Tclient")
public Set<Tadresse> getTadresses() {
return this.Tadresses;
}
public void setCodCategclient(final String codCategclient) {
this.codCategclient = codCategclient;
}
public void setCodCommuninsee(final String codCommuninsee) {
this.codCommuninsee = codCommuninsee;
}
public void setCodDeptnais(final String codDeptnais) {
this.codDeptnais = codDeptnais;
}
public void setCodFormjur(final String codFormjur) {
this.codFormjur = codFormjur;
}
public void setCodTiers(final BigDecimal codTiers) {
this.codTiers = codTiers;
}
public void setTadresses(final Set<Tadresse> Tadresses) {
this.Tadresses = Tadresses;
}
} |
Voici le hbm Tclient :
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
| <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
<class name="com.entities.pro.commun.Tclient" table="Tclient">
<id name="codTiers" type="big_decimal">
<column name="COD_TIERS" precision="0" />
<generator class="sequence">
<param name="sequence">TclientSEQ</param>
</generator>
</id>
<property name="codCategclient" type="string">
<column name="COD_CATEGCLIENT" length="3" />
</property>
<property name="codCommuninsee" type="string">
<column name="COD_COMMUNINSEE" length="5" />
</property>
<property name="codDeptnais" type="string">
<column name="COD_DEPTNAIS" length="3" />
</property>
<property name="codFormjur" type="string">
<column name="COD_FORMJUR" length="4" />
</property>
<set name="TAdresse" inverse="true" lazy="true" table="TADRESSE" fetch="select">
<key>
<column name="COD_TIERS" precision="0" not-null="true" />
</key>
<one-to-many class="com.entities.pro.commun.TADRESSE" />
</set>
</class>
</hibernate-mapping> |
voici entité détail TADRESSE :
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| package com.entities.pro.commun;
// Generated by Hibernate Tools 3.2.4.GA
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* TADRESSE generated by hbm2java
*/
@Entity
@Table(name = "TADRESSE")
public class TADRESSE implements java.io.Serializable {
private String adrAdrespost1;
private String adrAdrespost2;
private String adrCpostal;
private String codPaysadr;
private TADRESSEId id;
private Tclient tClient;
public TADRESSE() {
}
public TADRESSE(final TADRESSEId id, final Tclient tClient) {
this.id = id;
this.tClient = tClient;
}
public TADRESSE(final TADRESSEId id, final Tclient tClient, final String adrAdrespost1,final String adrAdrespost2,
final String adrCpostal,
final String codPaysadr) {
this.id = id;
this.tClient = tClient;
this.adrAdrespost1 = adrAdrespost1;
this.adrAdrespost2 = adrAdrespost2;
this.adrCpostal = adrCpostal;
this.codPaysadr = codPaysadr;
}
@Column(name = "ADR_ADRESPOST1", length = 32)
public String getAdrAdrespost1() {
return this.adrAdrespost1;
}
@Column(name = "ADR_ADRESPOST2", length = 32)
public String getAdrAdrespost2() {
return this.adrAdrespost2;
}
@Column(name = "ADR_CPOSTAL", length = 5)
public String getAdrCpostal() {
return this.adrCpostal;
}
@Column(name = "COD_PAYSADR", length = 3)
public String getCodPaysadr() {
return this.codPaysadr;
}
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "codTypadract", column = @Column(name = "COD_TYPADRACT", nullable = false, length = 3)),
@AttributeOverride(name = "codTiers", column = @Column(name = "COD_TIERS", nullable = false, precision = 0)) })
public
TADRESSEId getId() {
return this.id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "COD_TIERS", nullable = false, insertable = false, updatable = false)
public Tclient getTclient() {
return this.tClient;
}
public void setAdrAdrespost1(final String adrAdrespost1) {
this.adrAdrespost1 = adrAdrespost1;
}
public void setAdrAdrespost2(final String adrAdrespost2) {
this.adrAdrespost2 = adrAdrespost2;
}
public void setAdrCpostal(final String adrCpostal) {
this.adrCpostal = adrCpostal;
}
public void setCodPaysadr(final String codPaysadr) {
this.codPaysadr = codPaysadr;
}
public void setId(final TADRESSEId id) {
this.id = id;
}
public void setTclient(final Tclient tClient) {
this.tClient = tClient;
}
} |
voici le hbm :
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
| <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
<class name="com.entities.pro.commun.TAdresse" table="TADRESSE">
<composite-id name="id" class="com.entities.pro.commun.TADRESSEId">
<key-property name="codTypadract" type="string">
<column name="COD_TYPADRACT" length="3" />
</key-property>
<key-property name="codTiers" type="big_decimal">
<column name="COD_TIERS" precision="0" />
</key-property>
</composite-id>
<many-to-one name="Tclient" class="com.entities.pro.commun.Tclient" update="false" insert="false" fetch="select">
<column name="COD_TIERS" precision="0" not-null="true" />
</many-to-one>
<property name="adrAdrespost1" type="string">
<column name="ADR_ADRESPOST1" length="32" />
</property>
<property name="adrAdrespost2" type="string">
<column name="ADR_ADRESPOST2" length="32" />
</property>
<property name="adrCpostal" type="string">
<column name="ADR_CPOSTAL" length="5" />
<property name="codPaysadr" type="string">
<column name="COD_PAYSADR" length="3" />
</property>
</class>
</hibernate-mapping> |