IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

Mapping de <set>


Sujet :

Hibernate Java

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2010
    Messages : 6
    Points : 2
    Points
    2
    Par défaut Mapping de <set>
    Bonjour/Bonsoir,

    Je travail présentement sur un projet scolaire, j'ai pris la décision d'utiliser Hibernate pour la persistance de mes donnée.

    Voila, J'ai un problème avec les mapping <set> Dans la classe Enfant, j'ai un set de Parent. Quand je fini l'inscription de l'objet enfant, l'insertion se fait bien pour la table enfant mais rien pour la table parent (ni pour les 2 autres <set> dans la classe Enfant)

    Merci d'avance aux gens qui voudrons bien me donner un coup de main !

    Je joins à ce message les classes, fichiers mapping impliquer et le log..

    Classe Enfant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    131
    132
     
    package Model;
     
    import java.sql.Date;
    import java.util.HashSet;
    import java.util.Set;
     
    public class Enfant implements java.io.Serializable {
    	private String prenom;
    	private String nomFamille;
    	private Date dateNaissance;
    	private Date dateInsctiption;
    	private Set enfantAllergies = new HashSet();
    	private Set enfantPersonneauthorisees = new HashSet();
    	private char sexe;
    	private String commentaire;
    	private int iD;
    	private Garderie garderie;
    	private Set sibling = new HashSet();
    	private Set parent = new HashSet();
    	private Adresse adresse;
     
        public Enfant() {
        }
     
     
        public Adresse getAdresse() {
            return adresse;
        }
     
        public void setAdresse(Adresse adresse) {
            this.adresse = adresse;
        }
     
        public Set getEnfantAllergies() {
            return enfantAllergies;
        }
     
        public void setEnfantAllergies(Set enfantAllergies) {
            this.enfantAllergies = enfantAllergies;
        }
     
        public Set getEnfantPersonneauthorisees() {
            return enfantPersonneauthorisees;
        }
     
        public void setEnfantPersonneauthorisees(Set enfantPersonneauthorisees) {
            this.enfantPersonneauthorisees = enfantPersonneauthorisees;
        }
     
        public Set getParent() {
            return parent;
        }
     
        public void setParent(Set parent) {
            this.parent = parent;
        }
     
        public Set getSibling() {
            return sibling;
        }
     
        public void setSibling(Set sibling) {
            this.sibling = sibling;
        }  
     
        public String getCommentaire() {
            return commentaire;
        }
     
        public void setCommentaire(String commentaire) {
            this.commentaire = commentaire;
        }
     
        public Date getDateInsctiption() {
            return dateInsctiption;
        }
     
        public void setDateInsctiption(Date dateInsctiption) {
            this.dateInsctiption = dateInsctiption;
        }
     
        public Date getDateNaissance() {
            return dateNaissance;
        }
     
        public void setDateNaissance(Date dateNaissance) {
            this.dateNaissance = dateNaissance;
        }
     
        public Garderie getGarderie() {
            return garderie;
        }
     
        public void setGarderie(Garderie garderie) {
            this.garderie = garderie;
        }
     
        public int getiD() {
            return iD;
        }
     
        public void setiD(int iD) {
            this.iD = iD;
        }
     
        public String getNomFamille() {
            return nomFamille;
        }
     
        public void setNomFamille(String nomFamille) {
            this.nomFamille = nomFamille;
        }
     
        public String getPrenom() {
            return prenom;
        }
     
        public void setPrenom(String prenom) {
            this.prenom = prenom;
        }
     
        public char getSexe() {
            return sexe;
        }
     
        public void setSexe(char sexe) {
            this.sexe = sexe;
        }
     
     
    }
    Classe Parent
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
     
    package Model;
     
    import java.util.ArrayList;
     
    public class Parent implements java.io.Serializable {
    	private String prenom;
    	private String nomFamille;
    	private String telephoneMaison;
    	private String telephoneBureau;
    	private String telephoneCell;
    	private String courriel;
    	private String nas;
    	private String dateNaissance;
    	private String type;
    	private String commentaire;
    	private String nomUsager;
    	private String motPasse;
    	private int iD;
    	private Enfant enfant;
    //	private ArrayList<Compte> compte = new ArrayList<Compte>();
    	private Adresse adresse;
     
        public Parent() {
        }
     
        public Adresse getAdresse() {
            return adresse;
        }
     
        public void setAdresse(Adresse adresse) {
            this.adresse = adresse;
        }    
     
        public String getCommentaire() {
            return commentaire;
        }
     
        public void setCommentaire(String commentaire) {
            this.commentaire = commentaire;
        }
     
    //    public ArrayList<Compte> getCompte() {
    //        return compte;
    //    }
    //
    //    public void setCompte(ArrayList<Compte> compte) {
    //        this.compte = compte;
    //    }
     
        public String getCourriel() {
            return courriel;
        }
     
        public void setCourriel(String courriel) {
            this.courriel = courriel;
        }
     
        public String getDateNaissance() {
            return dateNaissance;
        }
     
        public void setDateNaissance(String dateNaissance) {
            this.dateNaissance = dateNaissance;
        }
     
        public Enfant getEnfant() {
            return enfant;
        }
     
        public void setEnfant(Enfant enfant) {
            this.enfant = enfant;
        }
     
        public int getiD() {
            return iD;
        }
     
        public void setiD(int iD) {
            this.iD = iD;
        }
     
        public String getMotPasse() {
            return motPasse;
        }
     
        public void setMotPasse(String motPasse) {
            this.motPasse = motPasse;
        }
     
        public String getNas() {
            return nas;
        }
     
        public void setNas(String nas) {
            this.nas = nas;
        }
     
        public String getNomFamille() {
            return nomFamille;
        }
     
        public void setNomFamille(String nomFamille) {
            this.nomFamille = nomFamille;
        }
     
        public String getNomUsager() {
            return nomUsager;
        }
     
        public void setNomUsager(String nomUsager) {
            this.nomUsager = nomUsager;
        }
     
        public String getPrenom() {
            return prenom;
        }
     
        public void setPrenom(String prenom) {
            this.prenom = prenom;
        }
     
        public String getTelephoneBureau() {
            return telephoneBureau;
        }
     
        public void setTelephoneBureau(String telephoneBureau) {
            this.telephoneBureau = telephoneBureau;
        }
     
        public String getTelephoneCell() {
            return telephoneCell;
        }
     
        public void setTelephoneCell(String telephoneCell) {
            this.telephoneCell = telephoneCell;
        }
     
        public String getTelephoneMaison() {
            return telephoneMaison;
        }
     
        public void setTelephoneMaison(String telephoneMaison) {
            this.telephoneMaison = telephoneMaison;
        }
     
        public String getType() {
            return type;
        }
     
        public void setType(String type) {
            this.type = type;
        }
     
     
    }
    Classe EnfantAllergie
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    package Model;
    // Generated 2011-05-04 19:53:39 by Hibernate Tools 3.2.1.GA
     
     
     
    /**
     * EnfantAllergie generated by hbm2java
     */
    public class EnfantAllergie  implements java.io.Serializable {
     
     
         private int iD;
         private Enfant enfant;
         private String allergie;
     
        public EnfantAllergie(Enfant enfant, String allergie) {
            this.enfant = enfant;
            this.allergie = allergie;
        }
     
     
     
        public EnfantAllergie() {
        }
     
        public int getiD() {
            return iD;
        }
     
        public void setiD(int iD) {
            this.iD = iD;
        }
     
        public Enfant getEnfant() {
            return this.enfant;
        }
     
        public void setEnfant(Enfant enfant) {
            this.enfant = enfant;
        }
        public String getAllergie() {
            return this.allergie;
        }
     
        public void setAllergie(String allergie) {
            this.allergie = allergie;
        }
     
     
     
     
    }
    Classe EnfantPersonneauthorisee
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    package Model;
    // Generated 2011-05-04 19:53:39 by Hibernate Tools 3.2.1.GA
     
     
     
    /**
     * EnfantPersonneauthorisee generated by hbm2java
     */
    public class EnfantPersonneauthorisee  implements java.io.Serializable {
     
     
         private int iD;
         private Enfant enfant;
         private String personneAuthorisee;
     
        public EnfantPersonneauthorisee() {
        }
     
        public EnfantPersonneauthorisee(Enfant enfant, String personneAuthorisee) {
            this.enfant = enfant;
            this.personneAuthorisee = personneAuthorisee;
        }        
     
        public int getiD() {
            return iD;
        }
     
        public void setiD(int iD) {
            this.iD = iD;
        }	    
     
        public Enfant getEnfant() {
            return this.enfant;
        }
     
        public void setEnfant(Enfant enfant) {
            this.enfant = enfant;
        }
        public String getPersonneAuthorisee() {
            return this.personneAuthorisee;
        }
     
        public void setPersonneAuthorisee(String personneAuthorisee) {
            this.personneAuthorisee = personneAuthorisee;
        }
     
     
     
     
    }
    Fichier Mapping Enfant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
        <class dynamic-insert="false" dynamic-update="false" mutable="true" name="Model.Enfant" optimistic-lock="version" polymorphism="implicit" select-before-update="false">
            <id column="enfantID" name="iD">
                <generator class="increment"/>
            </id>
            <property name="prenom"/>
            <property name="nomFamille"/>
            <property name="dateNaissance"/>
            <property name="dateInsctiption"/>
            <property name="sexe"/>
            <property name="commentaire"/>
            <many-to-one cascade="all" column="adesseID" name="adresse" not-null="false"/>
            <many-to-one cascade="all" column="garderieID" name="garderie" not-null="false"/>
     
            <set inverse="true" name="enfantPersonneauthorisees">
                <key>
                    <column name="enfantID" not-null="true"/>
                </key>
                <one-to-many class="Model.EnfantPersonneauthorisee"/>
            </set>
     
            <set inverse="true" name="enfantAllergies">
                <key>
                    <column name="enfantID" not-null="true"/>
                </key>
                <one-to-many class="Model.EnfantAllergie"/>
            </set>
     
            <set name="parent" inverse="true">
                <key>
                    <column name="enfantID" not-null="true" />
                </key>
                <one-to-many class="Model.Parent" />
            </set>
        </class>
    </hibernate-mapping>
    Fichier Mapping Parent
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
        <class dynamic-insert="false" dynamic-update="false" mutable="true" name="Model.Parent" optimistic-lock="version" polymorphism="implicit" select-before-update="false">
            <id column="parentID" name="iD">
                <generator class="increment"/>
            </id>
            <property name="prenom"/>
            <property name="nomFamille"/>
            <property name="telephoneMaison"/>
            <property name="telephoneBureau"/>
            <property name="telephoneCell"/>
            <property name="courriel"/>
            <property name="nas"/>
            <property name="dateNaissance"/>
            <property name="type"/>
            <property name="commentaire"/>
            <property name="nomUsager"/>
            <property name="motPasse"/>
            <many-to-one cascade="all" column="enfantID" name="enfant" not-null="false"/>
            <many-to-one cascade="all" column="adresseID" name="adresse" not-null="false"/>
        </class>
    </hibernate-mapping>
    Fichier Mapping EnfantPersonneauthorisee
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Generated 2011-05-04 19:53:44 by Hibernate Tools 3.2.1.GA -->
    <hibernate-mapping>
        <class catalog="gsdg" name="Model.EnfantPersonneauthorisee" table="enfant_personneauthorisee">
            <id column="enfantPersonneauthoriseeID" name="iD">
                <generator class="increment"/>
            </id>
            <many-to-one class="Model.Enfant" fetch="select" insert="false" name="enfant" update="false">
                <column name="EnfantID" not-null="true"/>
            </many-to-one>
            <property name="personneAuthorisee" type="string">
                <column name="PersonneAuthorisee"/>
            </property>
        </class>
    </hibernate-mapping>
    Fichier Mapping EnfantAllergie
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Generated 2011-05-04 19:53:44 by Hibernate Tools 3.2.1.GA -->
    <hibernate-mapping>
      <class catalog="gsdg" name="Model.EnfantAllergie" table="enfant_allergie">
        <id column="enfantAllergiID" name="iD">
          <generator class="increment"/>
        </id>
        <many-to-one class="Model.Enfant" fetch="select" insert="false" name="enfant" update="false">
          <column name="enfantID" not-null="true"/>
        </many-to-one>
        <property name="allergie" type="string">
          <column name="Allergie"/>
        </property>
      </class>
    </hibernate-mapping>
    Mon Fichier de configuration Hibernate
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/gsdga</property>
        <property name="hibernate.connection.username">gsdg_app</property>
        <property name="hibernate.connection.password">123456</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
        <property name="hibernate.show_sql">true</property>
        <mapping resource="Model/Adresse.hbm.xml"/>
        <mapping resource="Model/Garderie.hbm.xml"/>
        <mapping resource="Model/Gestionnaire.hbm.xml"/>
        <mapping resource="Model/Enfant.hbm.xml"/>
        <mapping resource="Model/EnfantAllergie.hbm.xml"/>
        <mapping resource="Model/EnfantPersonneauthorisee.hbm.xml"/>
        <mapping resource="Model/Parent.hbm.xml"/>
      </session-factory>
    </hibernate-configuration>

    Methode dans la quelle je fait le "save"
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
     
    public static boolean saveEnfant(Enfant e) {
     
            Session session = HibernateUtil.currentSession();
            Transaction tx = session.beginTransaction();
     
            try {
     
                session.saveOrUpdate(e);
                tx.commit();
                return true;
     
            } catch (Exception ex) {
                return false;
            } finally {
                HibernateUtil.closeSession();
            }
        }

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2010
    Messages : 6
    Points : 2
    Points
    2
    Par défaut Le log de l'operation
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/Adresse.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.Adresse -> Adresse
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/Garderie.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.Garderie -> Garderie
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/Gestionnaire.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.Gestionnaire -> Gestionnaire
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/Enfant.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.Enfant -> Enfant
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/EnfantAllergie.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.EnfantAllergie -> enfant_allergie
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/EnfantPersonneauthorisee.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.EnfantPersonneauthorisee -> enfant_personneauthorisee
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration addResource
    INFO: Reading mappings from resource : Model/Parent.hbm.xml
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
    INFO: Mapping class: Model.Parent -> Parent
    2011-05-15 21:35:40 org.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
    INFO: Mapping collection: Model.Enfant.enfantPersonneauthorisees -> enfant_personneauthorisee
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
    INFO: Mapping collection: Model.Enfant.enfantAllergies -> enfant_allergie
    2011-05-15 21:35:40 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
    INFO: Mapping collection: Model.Enfant.parent -> Parent
    2011-05-15 21:35:40 org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    2011-05-15 21:35:40 org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    2011-05-15 21:35:40 org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: autocommit mode: false
    2011-05-15 21:35:40 org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/gsdga
    2011-05-15 21:35:40 org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=gsdg_app, password=****}
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: RDBMS: MySQL, version: 5.1.35-community
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.13 ( Revision: ${bzr.revision-id} )
    2011-05-15 21:35:41 org.hibernate.dialect.Dialect <init>
    INFO: Using dialect: org.hibernate.dialect.MySQLDialect
    2011-05-15 21:35:41 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
    INFO: Using default transaction strategy (direct JDBC transactions)
    2011-05-15 21:35:41 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Automatic flush during beforeCompletion(): disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Automatic session close at end of transaction: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC batch size: 15
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC batch updates for versioned data: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Scrollable result sets: enabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC3 getGeneratedKeys(): enabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Connection release mode: auto
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Maximum outer join fetch depth: 2
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Default batch fetch size: 1
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Generate SQL with comments: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Order SQL updates by primary key: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Order SQL inserts for batching: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
    INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    2011-05-15 21:35:41 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
    INFO: Using ASTQueryTranslatorFactory
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JPA-QL strict compliance: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Second-level cache: enabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query cache: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory createCacheProvider
    INFO: Cache provider: org.hibernate.cache.NoCacheProvider
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Structured second-level cache entries: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Echoing all SQL to stdout
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Statistics: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Deleted entity synthetic identifier rollback: disabled
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Default entity-mode: pojo
    2011-05-15 21:35:41 org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Named query checking : enabled
    2011-05-15 21:35:41 org.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    2011-05-15 21:35:42 org.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    INFO: Running hbm2ddl schema update
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    INFO: fetching database metadata
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    INFO: updating schema
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdga.adresse
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [codepostal, province, ville, pays, adresseid, numerocivic, nomrue]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: []
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [primary]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdga.enfant
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [prenom, nomfamille, dateinsctiption, garderieid, sexe, commentaire, adesseid, enfantid, datenaissance]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: [fk7bfc540aadc8c528, fk7bfc540a86d6536a]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [fk7bfc540aadc8c528, primary, fk7bfc540a86d6536a]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdga.garderie
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [heurefermeture, garderieid, description, gestionnaireid, heureouverture, adesseid, nom, tarif]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: [fka2e92d35adc8c528, fka2e92d355428df00]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [fka2e92d35adc8c528, primary, fka2e92d355428df00]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdga.gestionnaire
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [prenom, garderieid, nomusager, gestionnaireid, motpasse, telephone, nom]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: [fk199f77a086d6536a]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [fk199f77a086d6536a, primary]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdga.parent
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [courriel, nomusager, parentid, telephonebureau, motpasse, telephonecell, type, enfantid, prenom, nomfamille, telephonemaison, adresseid, nas, commentaire, datenaissance]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: [fk8e0ff4ca5ff4514, fk8e0ff4caf7f198b4]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [fk8e0ff4ca5ff4514, primary, fk8e0ff4caf7f198b4]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdg.enfant_allergie
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [allergie, enfantallergiid, enfantid]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: [fk8fd61baa5ff4514]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [primary, fk8fd61baa5ff4514]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: table found: gsdg.enfant_personneauthorisee
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: columns: [enfantpersonneauthoriseeid, personneauthorisee, enfantid]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: foreign keys: [fk6b6226965ff4514]
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.TableMetadata <init>
    INFO: indexes: [primary, fk6b6226965ff4514]
    Hibernate: select max(enfantID) from Enfant
    Hibernate: select max(adresseID) from Adresse
    Hibernate: insert into Adresse (codePostal, nomRue, numeroCivic, pays, province, ville, adresseID) values (?, ?, ?, ?, ?, ?, ?)
    Hibernate: insert into Enfant (prenom, nomFamille, dateNaissance, dateInsctiption, sexe, commentaire, adesseID, garderieID, enfantID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
    Hibernate: update Garderie set description=?, heureFermeture=?, heureOuverture=?, nom=?, tarif=?, adesseID=?, gestionnaireID=? where garderieID=?
    2011-05-15 21:35:42 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    INFO: schema update complete
    Hibernate: update Adresse set codePostal=?, nomRue=?, numeroCivic=?, pays=?, province=?, ville=? where adresseID=?
    Hibernate: update Gestionnaire set nomUsager=?, motPasse=?, prenom=?, nom=?, telephone=?, garderieID=? where gestionnaireID=?

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2010
    Messages : 6
    Points : 2
    Points
    2
    Par défaut Personne ici ne peut m'aider avec ce problème?
    Personne ici ne peut m'aider avec ce problème?

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    230
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 230
    Points : 104
    Points
    104
    Par défaut
    J'ai regardé rapidement TOUT ton code, je pense qu'il manque la persistance transitive entre enfant et les classes qui le composent.....il faut que tu utilises cascade="save-update" dans le mapping afin de persister l'enfant et le père..etc...

  5. #5
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 481
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 481
    Points : 48 806
    Points
    48 806
    Par défaut
    tu dois effectivement mettre une cascade dans tes set pour t'assurer que le parent aussi est sauvé. De plus comme tes sets sont marqués "inverse=true" c'est le parent qui est chargé de sauver l'état de la relation parent<->enfant, donc tant que le parent n'est pas sauvé, la table de jointure ne sera pas mise à jour

Discussions similaires

  1. Réponses: 0
    Dernier message: 06/11/2008, 14h28
  2. Mapping collection <set>
    Par myrmidia dans le forum Hibernate
    Réponses: 5
    Dernier message: 14/08/2008, 13h20
  3. Réponses: 4
    Dernier message: 07/02/2008, 12h34
  4. Mapping d'un SET (Lazy)
    Par webtracker dans le forum Hibernate
    Réponses: 1
    Dernier message: 11/01/2008, 13h24
  5. Relation Parent/Fils - Mapping et Set
    Par --cycy dans le forum Hibernate
    Réponses: 1
    Dernier message: 17/09/2007, 17h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo