Hello,
Here is the problem i have with my application:
The 4 classes concerned are:
To resume I have 3 classes :
Parteners, Brochures and members.
The partners class contain a set of brochures, the brochure class have a set of members, and the members class have a set of partners.
When i make a saveorupdate of my member I have the foolowing Bug:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 180, of class: com.cci.marseille.pati.extranet.metier.EtablissementAdherent
I have this bug when i want to had a partner to a member and when the partner has created a brochure containing the member.
Do you know how to correct it?
This description of my application is just an application, in the reality i have 2 other classes which are used : EtablissementPartenaire and Professionnel. (I'm sorry but the class name are in french)
A partners (Partenaire) is a Professionnel.
An EtablissementPartenaire is linked with a partenaire.
Here is the mapping of these classes:
Code:
<class name="com.cci.marseille.pati.bTob.metier.Brochure" table="BROCHURE">
<id name="uid" type="long" column="UID" unsaved-value="-1">
<generator class="native"/>
</id>
<property name="lang" column="LANG" length="2" type="string" not-null="true"/>
<property name="date" column="DATE" type="timestamp"/>
<property name="codeClassement" column="CODE_CLASSEMENT" type="int"/>
<property name="image" column="IMAGE" type="boolean"/>
<property name="descriptif" column="DESCRPTIF" type="boolean"/>
<property name="contact" column="CONTACT" type="boolean"/>
<property name="coordonneesCompletes" column="COORDONNEES_COMPLETE" type="boolean"/>
<set name="etablissements" table="BROCHURE_ETABLISSEMENT_ADHERENT" cascade="none">
<key>
<column name="ID_BROCHURE"/>
</key>
<many-to-many class="com.cci.marseille.pati.extranet.metier.EtablissementAdherent">
<column name="ID_ETABLISSEMENT_ADHERENT"/>
</many-to-many>
</set>
</class>
<class name="com.cci.marseille.pati.bTob.metier.EtablissementPartenaire" table="ETABLISSEMENT_PARTENAIRE">
<id name="uid" column="UID" unsaved-value="-1">
<generator class="foreign">
<param name="property">administrateur</param>
</generator>
</id>
<!--one-to-one name="administrateur" constrained="true"/-->
<many-to-one name="administrateur" column="ID_PARTENAIRE" unique="true"/>
<property name="nom" column="NOM" length="50" type="string" not-null="true"/>
<property name="image" column="IMAGE" length="100" type="string"/>
<property name="email" column="EMAIL" length="50" type="string"/>
<property name="urlSite" column="SITE_WEB" length="100" type="string"/>
<property name="telephone" column="TELEPHONE" length="30" type="string"/>
<property name="fax" column="FAX" length="30" type="string"/>
<component
name="adresse"
class="com.cci.marseille.pati.common.metier.Adresse"
insert="true"
update="true">
<property name="numero" column="NUMERO" length="10" type="string"/>
<property name="typeVoie" column="TYPE_VOIE" length="15" type="string"/>
<property name="nomVoie" column="NOM_VOIE" length="80" type="string"/>
<property name="complement" column="COMPLEMENT_ADRESSE" length="100" type="string"/>
<property name="codePostal" column="CODE_POSTAL" length="10" type="string"/>
<property name="ville" column="VILLE" length="50" type="string"/>
<property name="pays" column="PAYS" length="32" type="string"/>
</component>
<list name="contacts" table="CONTACT_ETABLISSEMENT_PARTENAIRE" cascade="all">
<key column="UID_ETABLISSEMENT_PARTENAIRE"/>
<index column="INDEX_CONTACT" type="int" />
<composite-element class="com.cci.marseille.pati.common.metier.Contact" >
<property name="nom" column="NOM" length="50" type="string" not-null="true"/>
<property name="titre" column="TITRE" length="15" type="string" not-null="true"/>
<property name="fonction" column="FONCTION" length="50" type="string" not-null="true"/>
</composite-element>
</list>
<map name="descriptifs" table="TEXTE_DESCRIPTIF_ETABLISSEMENT_PARTENAIRE" cascade="all">
<key column="UID_ETABLISSEMENT_PARTENAIRE"/>
<index column="INDEX_LANG" length="2" type="string"/>
<composite-element class="com.cci.marseille.pati.common.utils.Texte" >
<property name="lang" column="LANG" length="2" type="string" not-null="true"/>
<!--property name="texte" column="TEXTE" type="string"/-->
<property name="texte" type="string">
<column name="TEXTE" sql-type="ntext"/>
</property>
</composite-element>
</map>
</class>
<class name="com.cci.marseille.pati.extranet.metier.EtablissementAdherent" table="ETABLISSEMENT_ADHERENT">
<id name="uid" type="long" column="uid" unsaved-value="-1">
<generator class="native"/>
</id>
<property name="nom" column="NOM" length="100" type="string" not-null="true"/>
<property name="image" column="IMAGE" length="100" type="string"/>
<property name="emailDirecteur" column="EMAIL_DIRECTEUR" length="50" type="string"/>
<property name="emailResponsableCommercial" column="EMAIL_RESPONSABLE_COMMERCIAL" length="50" type="string"/>
<property name="email" column="EMAIL" length="50" type="string"/>
<property name="urlSite" column="SITE_WEB" length="100" type="string"/>
<property name="telephone" column="TELEPHONE" length="30" type="string"/>
<property name="fax" column="FAX" length="30" type="string"/>
<property name="fichePreformatee" column="PREFORMATEE" type="boolean"/>
<property name="dateDerniereModificationInformations" column="LAST_MODIFICATION_DATE" type="timestamp"/>
<property name="informationsValidees" column="VALIDATED" type="boolean"/>
<property name="deblocageExceptionnel" column="DEBLOCAGE" type="boolean"/>
<one-to-one name="informationsComplementaires" cascade="all"/>
<many-to-one name="secteurActivite" column="ID_SECTEUR_ACTIVITE" not-null="true" class="com.cci.marseille.pati.extranet.metier.SecteurActivite" cascade="none"/>
<many-to-one name="thematique" column="ID_THEMATIQUE_SECTEUR_ACTIVITE" class="com.cci.marseille.pati.extranet.metier.ThematiqueSecteurActivite" cascade="none"/>
<many-to-one name="administrateur" column="ID_ADMNISTRATEUR" class="com.cci.marseille.pati.common.metier.user.Adherent" cascade="none"/>
<map name="descriptifsMissionPATI" table="DESCRIPTIFADHERENT_MISSION_PATI" cascade="all">
<key column="UID_ETABLISSMENT_ADHERENT"/>
<index column="INDEX_LANG" length="2" type="string"/>
<composite-element class="com.cci.marseille.pati.common.utils.Texte" >
<property name="lang" column="LANG" length="2" type="string" not-null="true"/>
<!--property name="texte" column="TEXTE" type="string"/-->
<property name="texte" type="string">
<column name="TEXTE" sql-type="ntext"/>
</property>
</composite-element>
</map>
<set name="partenaires" table="ETABLISSEMENT_ADHERENT_PARTENAIRE" cascade="none">
<key>
<column name="ID_ETABLISSMENT_ADHERENT"/>
</key>
<many-to-many class="com.cci.marseille.pati.bTob.metier.EtablissementPartenaire">
<column name="ID_ETABLISSEMENT_PARTENAIRE"/>
</many-to-many>
</set>
<set name="promotions" cascade="all" order-by="NUMERO_ORDRE asc">
<key column="UID_ETABLISSEMENT_ADHERENT"/>
<one-to-many class="com.cci.marseille.pati.extranet.metier.Promotion"/>
</set>
<component
name="adresse"
class="com.cci.marseille.pati.common.metier.Adresse"
insert="true"
update="true">
<property name="numero" column="NUMERO" length="10" type="string"/>
<property name="typeVoie" column="TYPE_VOIE" length="15" type="string"/>
<property name="nomVoie" column="NOM_VOIE" length="80" type="string"/>
<property name="complement" column="COMPLEMENT_ADRESSE" length="100" type="string"/>
<property name="codePostal" column="CODE_POSTAL" length="10" type="string"/>
<property name="ville" column="VILLE" length="50" type="string"/>
<property name="pays" column="PAYS" length="32" type="string"/>
</component>
<list name="contacts" table="CONTACT_ETABLISSEMENT_ADHERENT" cascade="all">
<key column="UID_ETABLISSEMENT_ADHERENT"/>
<index column="INDEX_CONTACT" type="int" />
<composite-element class="com.cci.marseille.pati.common.metier.Contact" >
<property name="nom" column="NOM" length="50" type="string" not-null="true"/>
<property name="titre" column="TITRE" length="15" type="string" not-null="true"/>
<property name="fonction" column="FONCTION" length="50" type="string" not-null="true"/>
</composite-element>
</list>
<list name="paragraphesDescriptions" table="PARAGRAPHE_DESCRIPTION_ETABLISSEMENT" cascade="all">
<key column="UID_ETABLISSEMENT_ADHERENT" />
<index column="INDEX_PARAGRAPHE" type="int" />
<composite-element class="com.cci.marseille.pati.extranet.metier.ParagrapheDescription" >
<property name="numero" column="NUMERO" type="int" not-null="true"/>
<property name="lang" column="LANG" length="2" type="string" not-null="true"/>
<property name="intitule" column="INTITULE" length="50" type="string"/>
<!--property name="texte" type="string" column="TEXTE"/-->
<property name="texte" type="string">
<column name="TEXTE" sql-type="ntext"/>
</property>
</composite-element>
</list>
</class>
<class name="com.cci.marseille.pati.common.metier.user.Utilisateur" table="UTILISATEUR">
<id name="uid" type="long" column="UID" unsaved-value="-1">
<generator class="native"/>
</id>
<discriminator column="ROLE" length="15" type="string"/>
<property name="login" column="LOGIN" length="30" type="string" not-null="true"/>
<property name="email" column="EMAIL" length="50" type="string" not-null="true"/>
<property name="password" column="PASSWORD" length="30" type="string" not-null="true"/>
<property name="dateDerniereConnexion" column="LAST_DATE" type="timestamp" />
<property name="nom" column="NOM" length="32" type="string" not-null="true"/>
<property name="prenom" column="PRENOM" length="32" type="string"/>
<property name="telephone" column="TELEPHONE" length="30" type="string"/>
<property name="fax" column="FAX" length="30" type="string"/>
<property name="url" column="URL" length="100" type="string"/>
<property name="organisme_societe" length="100" column="ORGANISME_SOCIETE" type="string"/>
<property name="nombreConnexions" column="NOMBRE_CONNEXIONS" type="int"/>
<component
name="adresse"
class="com.cci.marseille.pati.common.metier.Adresse"
insert="true"
update="true">
<property name="numero" column="NUMERO" length="10" type="string"/>
<property name="typeVoie" column="TYPE_VOIE" length="15" type="string"/>
<property name="nomVoie" column="NOM_VOIE" length="80" type="string"/>
<property name="complement" column="COMPLEMENT_ADRESSE" length="100" type="string"/>
<property name="codePostal" column="CODE_POSTAL" length="10" type="string"/>
<property name="ville" column="VILLE" length="50" type="string"/>
<property name="pays" column="PAYS" length="32" type="string"/>
</component>
<subclass name="com.cci.marseille.pati.common.metier.user.Adherent" discriminator-value="adherent">
<set name="etablissements" table="ADHERENT_ETABLISSEMENT" cascade="none" lazy="true">
<key>
<column name="ID_ADHERENT" not-null="true"/>
</key>
<many-to-many class="com.cci.marseille.pati.extranet.metier.EtablissementAdherent">
<column name="ID_ETABLISSEMENT" not-null="true"/>
</many-to-many>
</set>
</subclass>
<subclass name="com.cci.marseille.pati.common.metier.user.Professionnel" discriminator-value="professionnel">
<set name="marches" table="USER_MARCHE" cascade="none">
<key>
<column name="ID_USER" not-null="true"/>
</key>
<many-to-many class="com.cci.marseille.pati.bTob.metier.Marche">
<column name="ID_MARCHE" not-null="true"/>
</many-to-many>
</set>
<set name="brochures" cascade="all" order-by="DATE asc">
<key>
<column name="ID_PROFESSIONNEL_PARTENAIRE"/>
</key>
<one-to-many class="com.cci.marseille.pati.bTob.metier.Brochure"/>
</set>
<subclass name="com.cci.marseille.pati.common.metier.user.Partenaire" discriminator-value="partenaire">
<!--one-to-one name="etablissement" cascade="all" class="com.cci.marseille.pati.bTob.metier.EtablissementPartenaire"/-->
<one-to-one name="etablissement" class="com.cci.marseille.pati.bTob.metier.EtablissementPartenaire" property-ref="administrateur"/>
</subclass>
</subclass>
</class>
and the java code is:
Code:
public static void updateEtablissementAdherent(EtablissementAdherent etablissementAdherent)
throws PatiException {
Session s;
try {
s = HibernateUtil.currentSession();
etablissementAdherent.setDateDerniereModificationInformations(new Date());
s.saveOrUpdate(etablissementAdherent);
} catch (HibernateException e1) {
throw new PatiException(e1);
} finally {
}
}
I hope this message is clear.
Please help me, I have been working on this bug for several days and i can't find how to correct it.
Thank you,
Norbert