here are the 3 mapping files, as you can see, it seems very symetric
Code:
<hibernate-mapping>
<class name="com.auchan.balisage.bo.produit.Produit" table="PRODUIT">
<id column="ID_PRODUIT" name="idProduit" >
<generator class="sequence">
<param name="sequence">SEQ_PRODUIT</param>
</generator>
</id>
<property column="RIN" name="rin" not-null="true" />
<property column="LIBELLE" name="libelleProduit" not-null="true" />
<property column="LIBELLE_RPC" name="libelleRPC" not-null="false" />
<property column="PLUS_PRODUIT" name="plusProduit" not-null="true" />
<property column="DATE_CREATION" name="dateCreation" not-null="true" />
<property column="DATE_MODIFICATION" name="dateModification" not-null="true" />
<property column="ID_FAMILLE_RPC" name="idFamille" not-null="false" />
<property column="MISE_A_DISPOSITION" name="miseADisposition" not-null="false" />
<many-to-one column="ID_NOMENCLATURE" name="fiche" class="com.auchan.balisage.bo.segmentation.Nomenclature" not-null="false" />
<many-to-one name="marque" column="ID_MARQUE" />
<bag name="valeurs" lazy="true" inverse="true" cascade="all" table="VALEUR_CARACTERISTIQUE">
<key column="ID_PRODUIT"/>
<one-to-many column="ID_PRODUIT" class="com.auchan.balisage.bo.segmentation.ValeurCaracteristique"/>
</bag>
</class>
<hibernate-mapping>
<class name="com.auchan.balisage.bo.segmentation.Caracteristique" table="CARACTERISTIQUE">
<id column="ID_CARACTERISTIQUE" name="idCaracteristique" >
<generator class="sequence">
<param name="sequence">SEQ_GROUPE_CARACTERISTIQUE</param>
</generator>
</id>
<property column="NOM" name="nomCaracteristique" not-null="true" />
<property column="VALEUR_DEFAUT" name="valeurParDefaut" not-null="true" />
<property column="ID_GROUPE" name="idGroupe" not-null="true" />
<property column="ID_NOMENCLATURE" name="idNomenclature" not-null="true" />
<property column="DATE_MODIFICATION" name="dateModification" not-null="false" />
<property column="ORDRE" name="ordre" not-null="false" />
<property column="OBLIGATOIRE" name="obligatoire" not-null="false" />
<many-to-one name="unite" column="ID_UNITE" />
<many-to-one name="typeDonnees" column="ID_TYPE" />
<bag name="valeurs" lazy="true" inverse="true" cascade="all" table="VALEUR_CARACTERISTIQUE">
<key column="ID_CARACTERISTIQUE"/>
<one-to-many column="ID_CARACTERISTIQUE" class="com.auchan.balisage.bo.segmentation.ValeurCaracteristique"/>
</bag>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.auchan.balisage.bo.segmentation.ValeurCaracteristique" table="VALEUR_CARACTERISTIQUE">
<composite-id>
<key-many-to-one name="produit" class="com.auchan.balisage.bo.produit.Produit" column="ID_PRODUIT"/>
<key-many-to-one name="caracteristique" class="com.auchan.balisage.bo.segmentation.Caracteristique" column="ID_CARACTERISTIQUE"/>
</composite-id>
<property name="valeur" column="VALEUR" />
<property name="valeurBlob" column="OBJECT" />
<property name="dateCreation" column="DATE_CREATION" />
<property name="dateModification" column="DATE_MODIFICATION" />
</class>
</hibernate-mapping>
in the javaCode, a simple session.delete should work but in one side it doesn't.
Can this be related to something specific to release 2.0?
Is it related to cascade or inverse ?
Does a bad equals() method can break the system?
Code:
public boolean equals(Object other) {
if ( !(other instanceof ValeurCaracteristique) ) return false;
ValeurCaracteristique castOther = (ValeurCaracteristique) other;
return new EqualsBuilder()
.append(this.getProduit().getIdProduit(), castOther.getProduit().getIdProduit())
.append(this.getCaracteristique().getIdCaracteristique(), castOther.getCaracteristique().getIdCaracteristique())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getProduit().getIdProduit())
.append(getCaracteristique().getIdCaracteristique())
.toHashCode();
}
I know the problem must be in my code but i've spend all the morning with the developper, modify some code but no way to get it work well.
In practice, all the process do is:
1- open session
2- load Caracteristique or Produit
3- delete it
this process works for Produit but for Caracteristique you see what i must do...
very strange ...