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 :

SessionFactory creation failed.org.hibernate.MappingException


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Inscrit en
    Avril 2008
    Messages
    8
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 8
    Par défaut SessionFactory creation failed.org.hibernate.MappingException
    je suis débutante avec hibernate
    voici mon problème
    j'ai ceci


    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
    public class Activite 
    	private int duree;
    	private boolean dureeNull = true;
    	private short aFinal;
    	private boolean aFinalNull = true;
    	private String code;
    	private String name;
    	private java.util.UUID idActivite;
     
    	public Activite()
    	{
    	}
     
    	public int getDuree()
    	{
    		return duree;
    	}
    	public void setDuree(int duree)
    	{
    		this.duree = duree;
    		setDureeNull( false );
    	}
    	public void setDureeNull(boolean dureeNull)
    	{
    		this.dureeNull = dureeNull;
    	}
               public boolean isDureeNull()
    	{
    		return dureeNull;
    	}
     
    	public short getAFinal()
    	{
    		return aFinal;
    	}
     
    	public void setAFinal(short aFinal)
    	{
    		this.aFinal = aFinal;
    		setAFinalNull( false );
    	}
     
    	public void setAFinalNull(boolean aFinalNull)
    	{
    		this.aFinalNull = aFinalNull;
    	}
     
     
    	public boolean isAFinalNull()
    	{
    		return aFinalNull;
    	}
     
    	public java.lang.String getCode()
    	{
    		return code;
    	}
     
    	public void setCode(java.lang.String code)
    	{
    		this.code = code;
    	}
     
    	public java.lang.String getName()
    	{
    		return name;
    	}
     
     
    	public void setName(java.lang.String name)
    	{
    		this.name = name;
    	}
     
     
    	public java.util.UUID getIdActivite()
    	{
    		return idActivite;
    	}
     
     
    	public void setIdActivite(java.util.UUID idActivite)
    	{
    		this.idActivite = idActivite;
    	}
     
    }
    et voici le mapping associé

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <?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 name="com.mycompany.myapp.hibernate.Activite" table="activite">
        <id name="idActivite" column="id_activite">
          <generator class="increment" />
        </id>
        <property name="duree" column="duree" />
        <property name="aFinal" column="final" />
        <property name="code" column="code" not-null="true" />
        <property name="name" column="name" />
        <property name="idActivite" column="id_activite" not-null="true" />
      </class>
    </hibernate-mapping>

    voici le fichier conf
    Code xml : 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-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     
    <hibernate-configuration>
      <session-factory>
        <property name="connection.driver_class" >"org.postgresql.Driver"</property>
        <property name="connection.url" >"jdbc:postgresql://localhost:5432/BD_Mapping"</property>
        <property name="connection.username" >"postgres"</property>
        <property name="connection.password" >"postgres"</property>
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="show_sql">true</property>
        <mapping resource="hbm/Activite.hbm.xml" />
        <mapping resource="hbm/Ara.hbm.xml" />
        <mapping resource="hbm/Dossier.hbm.xml" />
        <mapping resource="hbm/DossierFlow.hbm.xml" />
        <mapping resource="hbm/Flow.hbm.xml" />
        <mapping resource="hbm/Message.hbm.xml" />
        <mapping resource="hbm/MessagePj.hbm.xml" />
        <mapping resource="hbm/PieceJointe.hbm.xml" />
        <mapping resource="hbm/Scenario.hbm.xml" />
        <mapping resource="hbm/ScenarioFlow.hbm.xml" />
        <mapping resource="hbm/Xsd.hbm.xml" />
      </session-factory>
    </hibernate-configuration>

    je veux insérer un objet activite dans la base mais j'ai ce résultat


    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    Initial SessionFactory creation failed.org.hibernate.MappingException: Repeated column in mapping for entity: com.mycompany.myapp.hibernate.DossierFlow column: id_flow (should be mapped with insert="false" update="false")
    Exception in thread "main" java.lang.ExceptionInInitializerError

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 23
    Par défaut
    A première vue, le problème ne vient pas de Activite.

    Mais plutot du mapping de DossierFlow et notamment sa colonne id_flow.

    "(should be mapped with insert="false" update="false")"

  3. #3
    Membre du Club
    Inscrit en
    Avril 2008
    Messages
    8
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 8
    Par défaut
    voici le mapping de dossierFlow
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <?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 name="com.mycompany.myapp.hibernate.DossierFlow" table="dossier_flow">
        <composite-id>
          <key-property name="idDossier" column="id_dossier"  />
          <key-property name="idFlow" column="id_flow"  />
        </composite-id>
        <property name="idDossier" column="id_dossier" not-null="true" />
        <property name="idFlow" column="id_flow" not-null="true"  />
      </class>
    </hibernate-mapping>

    je ne sais pas que dois je faire?

  4. #4
    Membre chevronné Avatar de JoloKossovar
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    532
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 532
    Par défaut
    Tu as deux colonne id_flow ... C'est ca le souci Si tu l'utilise déjà en composite id tu n'as pas besoin de l'avoir en property.

  5. #5
    Membre du Club
    Inscrit en
    Avril 2008
    Messages
    8
    Détails du profil
    Informations forums :
    Inscription : Avril 2008
    Messages : 8
    Par défaut
    ça n'a pas marché.j'ai le même résultat.

  6. #6
    Membre chevronné Avatar de JoloKossovar
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    532
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 532
    Par défaut
    y a id_dossier aussi

  7. #7
    Membre averti
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    23
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 23
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <?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 name="com.mycompany.myapp.hibernate.DossierFlow" table="dossier_flow">
    <composite-id>
    <key-property name="idDossier" column="id_dossier" />
    <key-property name="idFlow" column="id_flow" />
    </composite-id>
    </class>
    </hibernate-mapping>
    Le problème vient du fait que la colonne est repétée

    edit : je me suis fait devancer .

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 16/05/2013, 19h40
  2. Réponses: 4
    Dernier message: 11/06/2010, 13h29
  3. Réponses: 1
    Dernier message: 24/02/2009, 19h18
  4. premier exemple hibernate: org.hibernate.MappingException
    Par info_plus dans le forum Hibernate
    Réponses: 3
    Dernier message: 26/03/2008, 12h31
  5. Réponses: 3
    Dernier message: 09/10/2006, 14h11

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