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 :

MappingException: Association references unmapped class


Sujet :

Hibernate Java

  1. #1
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut MappingException: Association references unmapped class
    bonjour tt le monde,
    j'ai un pb avec Hibernate dont la trace de l'erreur est la suivante:

    0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.0.5
    15 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
    15 [main] INFO org.hibernate.cfg.Environment - using CGLIB reflection optimizer
    15 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
    78 [main] INFO org.hibernate.cfg.Configuration - Mapping resource: com/jmd/library/Clients.hbm.xml
    484 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: Clients -> clients
    500 [main] INFO org.hibernate.cfg.Configuration - Mapping resource: com/jmd/library/Commandes.hbm.xml
    547 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: Commandes -> commandes
    609 [main] INFO org.hibernate.cfg.Configuration - Mapping resource: com/jmd/library/Produits.hbm.xml
    640 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: Produits -> produits
    640 [main] INFO org.hibernate.cfg.Configuration - Mapping resource: com/jmd/library/DetailCommandes.hbm.xml
    672 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: DetailCommandes -> detailcommandes
    672 [main] INFO org.hibernate.cfg.Configuration - processing extends queue
    672 [main] INFO org.hibernate.cfg.Configuration - processing collection mappings
    Exception in thread "main" org.hibernate.MappingException: Association references unmapped class: com.jmd.library.Commandes
    at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2036)
    at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2497)
    at org.hibernate.cfg.HbmBinder$SecondPass.doSecondPass(HbmBinder.java:2468)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:884)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
    at com.jmd.library.HibernateTest.main(HibernateTest.java:32)
    mes classes ce sont dant le meme package :
    la classe Clients :

    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
    package com.jmd.library;
     
    import java.util.HashSet;
    import java.util.Set;
     
    public class Clients  implements java.io.Serializable {
     
     
        // Fields    
     
     
    	private static final long serialVersionUID = 1L;
    	private String cin;
         private String nom;
         private String prenom;
         private String adresse;
         private Set commandeses = new HashSet(0);
     
     
        // Constructors
     
        /** default constructor */
        public Clients() {
        	super();
        }
     
     
        /** full constructor */
        public Clients(String nom, String prenom, String adresse, Set commandeses) {
            this.nom = nom;
            this.prenom = prenom;
            this.adresse = adresse;
            this.commandeses = commandeses;
        }
     
     
        // Property accessors
     
        public Clients(String string, String string2, String string3) {
     
    	}
     
     
    	public String getCin() {
            return this.cin;
        }
     
        public void setCin(String cin) {
            this.cin = cin;
        }
     
        public String getNom() {
            return this.nom;
        }
     
        public void setNom(String nom) {
            this.nom = nom;
        }
     
        public String getPrenom() {
            return this.prenom;
        }
     
        public void setPrenom(String prenom) {
            this.prenom = prenom;
        }
     
        public String getAdresse() {
            return this.adresse;
        }
     
        public void setAdresse(String adresse) {
            this.adresse = adresse;
        }
     
        public Set getCommandeses() {
            return this.commandeses;
        }
     
        public void setCommandeses(Set commandeses) {
            this.commandeses = commandeses;
        }
       }
    et la classe Commandes:

    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
    package com.jmd.library;
     
    import java.util.Date;
    import java.util.HashSet;
    import java.util.Set;
     
    public class Commandes  implements java.io.Serializable {
     
    	private static final long serialVersionUID = 1L;
    	// Fields    
     
         private Integer numcom;
         private Clients clients;
         private Date date;
         private Set detailcommandeses = new HashSet(0);
     
     
        // Constructors
     
        /** default constructor */
        public Commandes() {
        	super();
        }
     
     
        /** full constructor */
        public Commandes(Clients clients, Date date, Set detailcommandeses) {
            this.clients = clients;
            this.date = date;
            this.detailcommandeses = detailcommandeses;
        }
     
     
        // Property accessors
     
        public Commandes(String string, Date date2) {
     
    	}
     
     
    	public Integer getNumcom() {
            return this.numcom;
        }
     
        public void setNumcom(Integer numcom) {
            this.numcom = numcom;
        }
     
        public Clients getClients() {
            return this.clients;
        }
     
        public void setClients(Clients clients) {
            this.clients = clients;
        }
     
        public Date getDate() {
            return this.date;
        }
     
        public void setDate(Date date) {
            this.date = date;
        }
     
        public Set getDetailcommandeses() {
            return this.detailcommandeses;
        }
     
        public void setDetailcommandeses(Set detailcommandeses) {
            this.detailcommandeses = detailcommandeses;
        }
       }
    et la classe Produits :

    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
    package com.jmd.library;
     
    import java.util.HashSet;
    import java.util.Set;
     
    public class Produits  implements java.io.Serializable {
     
     
        // Fields    
     
    	private static final long serialVersionUID = 1L;
    	private Integer reference;
         private String libelle;
         private Long prix;
         private Set detailcommandeses = new HashSet(0);
     
     
        // Constructors
     
        /** default constructor */
        public Produits() {
        	super();
        }
     
     
        /** full constructor */
        public Produits(String libelle, Long prix, Set detailcommandeses) {
            this.libelle = libelle;
            this.prix = prix;
            this.detailcommandeses = detailcommandeses;
        }
     
     
        // Property accessors
     
        public Produits(String string, String string2) {
     
    	}
     
     
    	public Integer getReference() {
            return this.reference;
        }
     
        public void setReference(Integer reference) {
            this.reference = reference;
        }
     
        public String getLibelle() {
            return this.libelle;
        }
     
        public void setLibelle(String libelle) {
            this.libelle = libelle;
        }
     
        public Long getPrix() {
            return this.prix;
        }
     
        public void setPrix(Long prix) {
            this.prix = prix;
        }
     
        public Set getDetailcommandeses() {
            return this.detailcommandeses;
        }
     
        public void setDetailcommandeses(Set detailcommandeses) {
            this.detailcommandeses = detailcommandeses;
        }
       }
    et la classe DetailCommandes :

    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
    package com.jmd.library;
     
    public class DetailCommandes  implements java.io.Serializable {
     
     
        // Fields    
     
    	private static final long serialVersionUID = 1L;
    	private String id;
         private Produits produits;
         private Commandes commandes;
         private Integer qte;
     
     
        // Constructors
     
        /** default constructor */
        public DetailCommandes() {
        	super();
        }
     
    	/** minimal constructor */
        public DetailCommandes(Produits produits, Commandes commandes) {
            this.produits = produits;
            this.commandes = commandes;
        }
     
        /** full constructor */
        public DetailCommandes(Produits produits, Commandes commandes, Integer qte) {
            this.produits = produits;
            this.commandes = commandes;
            this.qte = qte;
        }
     
     
        // Property accessors
     
        public DetailCommandes(String string, String string2, String string3) {
     
    	}
     
    	public String getId() {
            return this.id;
        }
     
        public void setId(String id) {
            this.id = id;
        }
     
        public Produits getProduits() {
            return this.produits;
        }
     
        public void setProduits(Produits produits) {
            this.produits = produits;
        }
     
        public Commandes getCommandes() {
            return this.commandes;
        }
     
        public void setCommandes(Commandes commandes) {
            this.commandes = commandes;
        }
     
        public Integer getQte() {
            return this.qte;
        }
     
        public void setQte(Integer qte) {
            this.qte = qte;
        }
       }
    et les fichiers mapping placées dant le meme package :

    Clients.hbm.xml :

    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
    25
    26
    27
    28
    29
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="Clients" table="clients" schema="dbo" catalog="DBbase1">
            <id name="cin" type="java.lang.String">
                <column name="cin" length="10" />
                <generator class="sequence"></generator>
            </id>
            <property name="nom" type="java.lang.String">
                <column name="nom" />
            </property>
            <property name="prenom" type="java.lang.String">
                <column name="prenom" />
            </property>
            <property name="adresse" type="java.lang.String">
                <column name="adresse" />
            </property>
            <set name="commandeses" inverse="true">
                <key>
                    <column name="cin" length="10" />
                </key>
                <one-to-many class="com.jmd.library.Commandes" />
            </set>
        </class>
    </hibernate-mapping>

    et Commandes.hbm.xml :

    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
    25
    26
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="Commandes" table="commandes" schema="dbo" catalog="DBbase1">
            <id name="numcom" type="java.lang.Integer">
                <column name="numcom" />
                <generator class="sequence"></generator>
            </id>
            <many-to-one name="clients" class="Clients" fetch="select">
                <column name="cin" length="10" />
            </many-to-one>
            <property name="date" type="java.util.Date">
                <column name="date" length="23" />
            </property>
            <set name="detailcommandeses" inverse="true">
                <key>
                    <column name="numcom" not-null="true" />
                </key>
                <one-to-many class="com.jmd.library.Detailcommandes" />
            </set>
        </class>
    </hibernate-mapping>

    et Produits.hbm.xml :

    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
    25
    26
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="Produits" table="produits" schema="dbo" catalog="DBbase1">
            <id name="reference" type="java.lang.Integer">
                <column name="reference" />
                <generator class="sequence"></generator>
            </id>
            <property name="libelle" type="java.lang.String">
                <column name="libelle" />
            </property>
            <property name="prix" type="java.lang.Long">
                <column name="prix" precision="18" scale="0" />
            </property>
            <set name="detailcommandeses" inverse="true">
                <key>
                    <column name="reference" not-null="true" />
                </key>
                <one-to-many class="com.jmd.library.Detailcommandes" />
            </set>
        </class>
    </hibernate-mapping>

    et DetailCommandes.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- 
        Mapping file autogenerated by MyEclipse - Hibernate Tools
    -->
    <hibernate-mapping>
        <class name="DetailCommandes" table="detailcommandes" schema="dbo" catalog="DBbase1">
            <id name="id" type="java.lang.String">
                <column name="id" length="10" />
                <generator class="sequence"></generator>
            </id>
            <many-to-one name="produits" class="Produits" fetch="select">
                <column name="reference" not-null="true" />
            </many-to-one>
            <many-to-one name="commandes" class="Commandes" fetch="select">
                <column name="numcom" not-null="true" />
            </many-to-one>
            <property name="qte" type="java.lang.Integer">
                <column name="qte" />
            </property>
        </class>
    </hibernate-mapping>

    et le fichier de HibernateTest.java placé dans le meme package :

    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
    package com.jmd.library;
     
    import java.util.Date;
     
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    import org.hibernate.classic.Session;
     
    public class HibernateTest {
     
    public static void main(String args[]) 
     
    throws Exception {
     
    Configuration config = new Configuration();
     
    config.addClass(Clients.class);
    config.addClass(Commandes.class);
    config.addClass(Produits.class);
    config.addClass(DetailCommandes.class);
     
    config.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
    config.setProperty("myeclipse.connection.profile", "BaseCommandes");
    config.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://localhost:1433");
    config.setProperty("hibernate.connection.username", "khalil");
    config.setProperty("hibernate.connection.password", "password");
    config.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver");
     
     
     
    SessionFactory sessionFactory = config.buildSessionFactory();
    Session session = sessionFactory.openSession();
    Transaction tx = null;
     
    try {
    tx = session.beginTransaction();
    Clients clients = new Clients("nom", "prenom", "adresse");
    session.save(clients);
    session.flush() ;
    tx.commit();
    //session.connection();
     
    tx = session.beginTransaction();
    Produits produits = new Produits("prix", "libelle");
    session.save(produits);
    session.flush();
    tx.commit();
    //session.connection();
     
    tx = session.beginTransaction();
    Commandes commandes = new Commandes("cin", new Date());
    session.save(commandes);
    session.flush();
    tx.commit();
    //session.connection();
     
    tx = session.beginTransaction();
    DetailCommandes detailcommandes = new DetailCommandes("numcom", "reference", "qte");
    session.save(detailcommandes);
    session.flush();
    tx.commit();
    //session.connection();
    }
     
    catch (Exception e) {
    if (tx != null) {
    tx.rollback();
    }
     
    throw e;
    }
    finally {
    session.close();
    }
    sessionFactory.close();
    }
    }
    et le fichier HibernateSessionFactory.java dans le package par defaut 1 autre :

    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
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.cfg.Configuration;
     
    public class HibernateSessionFactory {
     
     
        private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
     
        /** Holds a single instance of Session */
    	private static final ThreadLocal threadLocal = new ThreadLocal();
     
        /** The single instance of hibernate configuration */
        private static final Configuration cfg = new Configuration();
     
        /** The single instance of hibernate SessionFactory */
        private static org.hibernate.SessionFactory sessionFactory;
     
        public static Session currentSession() throws HibernateException {
            Session session = (Session) threadLocal.get();
     
    		if (session == null || !session.isOpen()) {
    			if (sessionFactory == null) {
    				try {
    					cfg.configure(CONFIG_FILE_LOCATION);
    					sessionFactory = cfg.buildSessionFactory();
    				} catch (Exception e) {
    					System.err
    							.println("%%%% Error Creating SessionFactory %%%%");
    					e.printStackTrace();
    				}
    			}
    			session = (sessionFactory != null) ? sessionFactory.openSession()
    					: null;
    			threadLocal.set(session);
    		}
     
            return session;
        }
     
     
        public static void closeSession() throws HibernateException {
            Session session = (Session) threadLocal.get();
            threadLocal.set(null);
     
            if (session != null) {
                session.close();
            }
        }
     
        /**
         * Default constructor.
         */
        private HibernateSessionFactory() {
        }
     
    }
    et le fichier Hibernate.cfg.xml :

    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">
     
    <!-- Generated by MyEclipse Hibernate Tools.                   -->
    <hibernate-configuration>
     
    	<session-factory>
    		<property name="connection.username">khalil</property>
    		<property name="connection.url">jdbc:microsoft:sqlserver://localhost:1433</property>
    		<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
    		<property name="myeclipse.connection.profile">BaseCommandes</property>
    		<property name="connection.password">password</property>
    		<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
     
    		<mapping resource="Clients.hbm.xml"></mapping>
    		<mapping resource="Commandes.hbm.xml"></mapping>
    		<mapping resource="Produits.hbm.xml"></mapping>
    		<mapping resource="DetailCommandes.hbm.xml"></mapping>
     
    	</session-factory>
     
    </hibernate-configuration>

    merci d'avance mes amis.

  2. #2
    Membre expérimenté Avatar de a.snaps
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    209
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 209
    Par défaut
    regarde l'attribut "package" du tag <hibernate-mapping> dans la doc...
    Alex

  3. #3
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    j ai un nouveau probleme :

    Exception in thread "main" org.hibernate.MappingException: entity class not found: Produits
    at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:89)
    at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:160)
    at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:42)
    at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:108)
    at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
    at com.jmd.library.HibernateTest.main(HibernateTest.java:31)
    Caused by: java.lang.ClassNotFoundException: Produits
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
    at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:86)
    ... 9 more

  4. #4
    Membre averti
    Inscrit en
    Février 2007
    Messages
    18
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 18
    Par défaut
    mes classes sont :

    la classe Clients :

    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
    package com.jmd.library;
     
    public class Clients{
     
    	private static final long serialVersionUID = 1L;
    	// Fields    
     
    	 private String cin;
         private String nom;
         private String prenom;
         private String adresse;
     
     
        // Constructors
     
        /** default constructor */
        public Clients() {
        }
     
        public Clients(String cin, String nom, String prenom, String adresse){
        	this.cin = cin;
        	this.adresse = adresse;
        	this.nom = nom;
        	this.prenom = prenom;
        }
     
        public String getCin() {
        	return cin;
        }
     
        public void setCin(String cin) {
        	this.cin = cin;
        }
     
        public String getNom() {
        	return nom;
        }
     
        public void setNom(String nom) {
        	this.nom = nom;
        }
     
        public String getPrenom() {
        	return prenom;
        }
     
        public void setPrenom(String prenom){
        	this.prenom = prenom;
        }
     
       public String getAdresse(){
    	   return adresse;
       }
     
       public void setAdresse(String adresse){
    	   this.adresse = adresse;
       }
      }
    la classe Commandes :

    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 com.jmd.library;
     
    import java.util.Date;
     
    public class Commandes{
     
    	private static final long serialVersionUID = 1L;
     
    	// Fields    
     
         private Integer numcom;
         private Date date;
         private String cin;
     
     
        // Constructors
     
        /** default constructor */
        public Commandes() {
         }
     
        public Commandes(Integer numcom, Date date, String cin){
        	this.date = date;
        	this.numcom = numcom;
        	this.cin = cin;
        }
     
        public Date getDate() {
            return date;
        }
     
        public void setDate(Date date) {
            this.date = date;
        }
     
       public Integer getNumcom(){
    	   return numcom;
       }
     
       public void setNumcom(Integer numcom){
    	   this.numcom = numcom;
       }
     
       public String getCin() {
       	return cin;
       }
     
       public void setCin(String cin) {
       	this.cin = cin;
       }
      }
    la classe Produits :

    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
    package com.jmd.library;
     
    public class Produits {
     
        // Fields    
     
    	 private static final long serialVersionUID = 1L;
       	 private Integer reference;
         private String libelle;
         private Long prix;
     
        // Constructors
     
        /** default constructor */
        public Produits() {
        }
     
        public Produits(Integer reference, String libelle, Long prix){
        	this.libelle = libelle;
        	this.prix = prix;
        	this.reference = reference;
        }
     
    	public Integer getReference() {
            return this.reference;
        }
     
        public void setReference(Integer reference) {
            this.reference = reference;
        }
     
        public String getLibelle() {
            return this.libelle;
        }
     
        public void setLibelle(String libelle) {
            this.libelle = libelle;
        }
     
        public Long getPrix() {
            return this.prix;
        }
     
        public void setPrix(Long prix) {
            this.prix = prix;
        }
     }
    la classe DetailCommandes :

    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
    package com.jmd.library;
     
    public class DetailCommandes{
     
        // Fields    
     
    	 private static final long serialVersionUID = 1L;
    	 private String id;
         private Integer qte;
         private Integer reference;
         private Integer numcom;
     
        // Constructors
     
        /** default constructor */
        public DetailCommandes() {
        }
     
        /** full constructor */
        public DetailCommandes(Integer qte, Integer reference, Integer numcom, String id) {
        	this.id = id;
        	this.numcom = numcom;
        	this.qte = qte;
        	this.reference = reference;
    	}
     
    	public String getId() {
            return this.id;
        }
     
        public void setId(String id) {
            this.id = id;
        }
     
        public Integer getQte() {
            return this.qte;
        }
     
        public void setQte(Integer qte) {
            this.qte = qte;
        }
     
        public Integer getReference() {
            return this.reference;
        }
     
        public void setReference(Integer reference) {
            this.reference = reference;
        }
     
        public Integer getNumcom(){
     	   return numcom;
        }
     
        public void setNumcom(Integer numcom){
     	   this.numcom = numcom;
        }
       }
    la classe HibernateTest :

    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
    package com.jmd.library;
     
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
     
     
    public class HibernateTest {
     
    public static void main(String args[]) 
     
    throws Exception {
     
    Configuration config = new Configuration();
     
    config.addClass(Clients.class);
    config.addClass(Commandes.class);
    config.addClass(Produits.class);
    config.addClass(DetailCommandes.class);
     
    config.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
    config.setProperty("myeclipse.connection.profile", "BaseCommandes");
    config.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://localhost:1433");
    config.setProperty("hibernate.connection.username", "khalil");
    config.setProperty("hibernate.connection.password", "password");
    config.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver");
     
     
     
    SessionFactory sessionFactory = config.buildSessionFactory();
    Session session = sessionFactory.openSession();
    Transaction tx = null;
     
    try {
    tx = session.beginTransaction();
    Clients clients = new Clients();
    session.save(clients);
    session.flush() ;
    tx.commit();
     
     
    tx = session.beginTransaction();
    Produits produits = new Produits();
    session.save(produits);
    session.flush();
    tx.commit();
     
     
    tx = session.beginTransaction();
    Commandes commandes = new Commandes();
    session.save(commandes);
    session.flush();
    tx.commit();
     
     
    tx = session.beginTransaction();
    DetailCommandes detailcommandes = new DetailCommandes();
    session.save(detailcommandes);
    session.flush();
    tx.commit();
     
    }
     
    catch (Exception e) {
    if (tx != null) {
    tx.rollback();
    }
     
    throw e;
    }
    finally {
    session.close();
    }
    sessionFactory.close();
    }
    }
    et le fichier Clients.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="Clients" table="clients" schema="dbo" catalog="DBbase1">
            <id name="cin" type="java.lang.String">
                <column name="cin" length="10" />
                <generator class="native"></generator>
            </id>
            <property name="nom" type="java.lang.String">
                <column name="nom" />
            </property>
            <property name="prenom" type="java.lang.String">
                <column name="prenom" />
            </property>
            <property name="adresse" type="java.lang.String">
                <column name="adresse" />
            </property>
            <set name="commandes" inverse="true">
                <key>
                    <column name="cin" length="10" />
                </key>
                <one-to-many class="Commandes" />
            </set>
        </class>
    </hibernate-mapping>
    le fichier Commandes.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="Clients" table="clients" schema="dbo" catalog="DBbase1">
            <id name="cin" type="java.lang.String">
                <column name="cin" length="10" />
                <generator class="native"></generator>
            </id>
            <property name="nom" type="java.lang.String">
                <column name="nom" />
            </property>
            <property name="prenom" type="java.lang.String">
                <column name="prenom" />
            </property>
            <property name="adresse" type="java.lang.String">
                <column name="adresse" />
            </property>
            <set name="commandes" inverse="true">
                <key>
                    <column name="cin" length="10" />
                </key>
                <one-to-many class="Commandes" />
            </set>
        </class>
    </hibernate-mapping>
    le fichier Produits.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="Produits" table="produits" schema="dbo" catalog="DBbase1">
            <id name="reference" type="java.lang.Integer">
                <column name="reference" />
                <generator class="native"></generator>
            </id>
            <property name="libelle" type="java.lang.String">
                <column name="libelle" />
            </property>
            <property name="prix" type="java.lang.Long">
                <column name="prix" precision="18" scale="0" />
            </property>
            <set name="detailcommandes" inverse="true">
                <key>
                    <column name="reference" not-null="true" />
                </key>
                <one-to-many class="DetailCommandes" />
            </set>
        </class>
    </hibernate-mapping>
    le fichier DetailCommandes.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="DetailCommandes" table="detailcommandes" schema="dbo" catalog="DBbase1">
            <id name="id" type="java.lang.String">
                <column name="id" length="10" />
                <generator class="native"></generator>
            </id>
            <many-to-one name="produits" class="Produits" fetch="select">
                <column name="reference" not-null="true" />
            </many-to-one>
            <many-to-one name="commandes" class="Commandes" fetch="select">
                <column name="numcom" not-null="true" />
            </many-to-one>
            <property name="qte" type="java.lang.Integer">
                <column name="qte" />
            </property>
        </class>
    </hibernate-mapping>
    et le fichier hibernate.cfg.xml :

    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-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     
    <!-- Generated by MyEclipse Hibernate Tools. -->
    <hibernate-configuration>
     
    	<session-factory>
    		<property name="connection.username">khalil</property>
    		<property name="connection.url">jdbc:microsoft:sqlserver://localhost:1433</property>
    		<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
    		<property name="myeclipse.connection.profile">BaseCommandes</property>
    		<property name="connection.password">password</property>
    		<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
     
    		<mapping resource="Produits.hbm.xml" />
    		<mapping resource="Commandes.hbm.xml" />
    		<mapping resource="DetailCommandes.hbm.xml" />
    		<mapping resource="Clients.hbm.xml" />
     
    	</session-factory>
     
    </hibernate-configuration>
    é merci d'avance.

  5. #5
    Membre averti
    Profil pro
    ingénieur
    Inscrit en
    Octobre 2004
    Messages
    58
    Détails du profil
    Informations personnelles :
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : ingénieur

    Informations forums :
    Inscription : Octobre 2004
    Messages : 58
    Par défaut
    Slt,

    As tu résolu ton pb ?

    Il me semblerai bien que j'ai le meme souci...



    Citation Envoyé par solfegepro Voir le message
    mes classes sont :

    la classe Clients :

    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
    package com.jmd.library;
     
    public class Clients{
     
    	private static final long serialVersionUID = 1L;
    	// Fields    
     
    	 private String cin;
         private String nom;
         private String prenom;
         private String adresse;
     
     
        // Constructors
     
        /** default constructor */
        public Clients() {
        }
     
        public Clients(String cin, String nom, String prenom, String adresse){
        	this.cin = cin;
        	this.adresse = adresse;
        	this.nom = nom;
        	this.prenom = prenom;
        }
     
        public String getCin() {
        	return cin;
        }
     
        public void setCin(String cin) {
        	this.cin = cin;
        }
     
        public String getNom() {
        	return nom;
        }
     
        public void setNom(String nom) {
        	this.nom = nom;
        }
     
        public String getPrenom() {
        	return prenom;
        }
     
        public void setPrenom(String prenom){
        	this.prenom = prenom;
        }
     
       public String getAdresse(){
    	   return adresse;
       }
     
       public void setAdresse(String adresse){
    	   this.adresse = adresse;
       }
      }
    la classe Commandes :

    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 com.jmd.library;
     
    import java.util.Date;
     
    public class Commandes{
     
    	private static final long serialVersionUID = 1L;
     
    	// Fields    
     
         private Integer numcom;
         private Date date;
         private String cin;
     
     
        // Constructors
     
        /** default constructor */
        public Commandes() {
         }
     
        public Commandes(Integer numcom, Date date, String cin){
        	this.date = date;
        	this.numcom = numcom;
        	this.cin = cin;
        }
     
        public Date getDate() {
            return date;
        }
     
        public void setDate(Date date) {
            this.date = date;
        }
     
       public Integer getNumcom(){
    	   return numcom;
       }
     
       public void setNumcom(Integer numcom){
    	   this.numcom = numcom;
       }
     
       public String getCin() {
       	return cin;
       }
     
       public void setCin(String cin) {
       	this.cin = cin;
       }
      }
    la classe Produits :

    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
    package com.jmd.library;
     
    public class Produits {
     
        // Fields    
     
    	 private static final long serialVersionUID = 1L;
       	 private Integer reference;
         private String libelle;
         private Long prix;
     
        // Constructors
     
        /** default constructor */
        public Produits() {
        }
     
        public Produits(Integer reference, String libelle, Long prix){
        	this.libelle = libelle;
        	this.prix = prix;
        	this.reference = reference;
        }
     
    	public Integer getReference() {
            return this.reference;
        }
     
        public void setReference(Integer reference) {
            this.reference = reference;
        }
     
        public String getLibelle() {
            return this.libelle;
        }
     
        public void setLibelle(String libelle) {
            this.libelle = libelle;
        }
     
        public Long getPrix() {
            return this.prix;
        }
     
        public void setPrix(Long prix) {
            this.prix = prix;
        }
     }
    la classe DetailCommandes :

    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
    package com.jmd.library;
     
    public class DetailCommandes{
     
        // Fields    
     
    	 private static final long serialVersionUID = 1L;
    	 private String id;
         private Integer qte;
         private Integer reference;
         private Integer numcom;
     
        // Constructors
     
        /** default constructor */
        public DetailCommandes() {
        }
     
        /** full constructor */
        public DetailCommandes(Integer qte, Integer reference, Integer numcom, String id) {
        	this.id = id;
        	this.numcom = numcom;
        	this.qte = qte;
        	this.reference = reference;
    	}
     
    	public String getId() {
            return this.id;
        }
     
        public void setId(String id) {
            this.id = id;
        }
     
        public Integer getQte() {
            return this.qte;
        }
     
        public void setQte(Integer qte) {
            this.qte = qte;
        }
     
        public Integer getReference() {
            return this.reference;
        }
     
        public void setReference(Integer reference) {
            this.reference = reference;
        }
     
        public Integer getNumcom(){
     	   return numcom;
        }
     
        public void setNumcom(Integer numcom){
     	   this.numcom = numcom;
        }
       }
    la classe HibernateTest :

    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
    package com.jmd.library;
     
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
     
     
    public class HibernateTest {
     
    public static void main(String args[]) 
     
    throws Exception {
     
    Configuration config = new Configuration();
     
    config.addClass(Clients.class);
    config.addClass(Commandes.class);
    config.addClass(Produits.class);
    config.addClass(DetailCommandes.class);
     
    config.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect");
    config.setProperty("myeclipse.connection.profile", "BaseCommandes");
    config.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://localhost:1433");
    config.setProperty("hibernate.connection.username", "khalil");
    config.setProperty("hibernate.connection.password", "password");
    config.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver");
     
     
     
    SessionFactory sessionFactory = config.buildSessionFactory();
    Session session = sessionFactory.openSession();
    Transaction tx = null;
     
    try {
    tx = session.beginTransaction();
    Clients clients = new Clients();
    session.save(clients);
    session.flush() ;
    tx.commit();
     
     
    tx = session.beginTransaction();
    Produits produits = new Produits();
    session.save(produits);
    session.flush();
    tx.commit();
     
     
    tx = session.beginTransaction();
    Commandes commandes = new Commandes();
    session.save(commandes);
    session.flush();
    tx.commit();
     
     
    tx = session.beginTransaction();
    DetailCommandes detailcommandes = new DetailCommandes();
    session.save(detailcommandes);
    session.flush();
    tx.commit();
     
    }
     
    catch (Exception e) {
    if (tx != null) {
    tx.rollback();
    }
     
    throw e;
    }
    finally {
    session.close();
    }
    sessionFactory.close();
    }
    }
    et le fichier Clients.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="Clients" table="clients" schema="dbo" catalog="DBbase1">
            <id name="cin" type="java.lang.String">
                <column name="cin" length="10" />
                <generator class="native"></generator>
            </id>
            <property name="nom" type="java.lang.String">
                <column name="nom" />
            </property>
            <property name="prenom" type="java.lang.String">
                <column name="prenom" />
            </property>
            <property name="adresse" type="java.lang.String">
                <column name="adresse" />
            </property>
            <set name="commandes" inverse="true">
                <key>
                    <column name="cin" length="10" />
                </key>
                <one-to-many class="Commandes" />
            </set>
        </class>
    </hibernate-mapping>
    le fichier Commandes.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="Clients" table="clients" schema="dbo" catalog="DBbase1">
            <id name="cin" type="java.lang.String">
                <column name="cin" length="10" />
                <generator class="native"></generator>
            </id>
            <property name="nom" type="java.lang.String">
                <column name="nom" />
            </property>
            <property name="prenom" type="java.lang.String">
                <column name="prenom" />
            </property>
            <property name="adresse" type="java.lang.String">
                <column name="adresse" />
            </property>
            <set name="commandes" inverse="true">
                <key>
                    <column name="cin" length="10" />
                </key>
                <one-to-many class="Commandes" />
            </set>
        </class>
    </hibernate-mapping>
    le fichier Produits.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="Produits" table="produits" schema="dbo" catalog="DBbase1">
            <id name="reference" type="java.lang.Integer">
                <column name="reference" />
                <generator class="native"></generator>
            </id>
            <property name="libelle" type="java.lang.String">
                <column name="libelle" />
            </property>
            <property name="prix" type="java.lang.Long">
                <column name="prix" precision="18" scale="0" />
            </property>
            <set name="detailcommandes" inverse="true">
                <key>
                    <column name="reference" not-null="true" />
                </key>
                <one-to-many class="DetailCommandes" />
            </set>
        </class>
    </hibernate-mapping>
    le fichier DetailCommandes.hbm.xml :

    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
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools -->
     
    <hibernate-mapping>
        <class name="DetailCommandes" table="detailcommandes" schema="dbo" catalog="DBbase1">
            <id name="id" type="java.lang.String">
                <column name="id" length="10" />
                <generator class="native"></generator>
            </id>
            <many-to-one name="produits" class="Produits" fetch="select">
                <column name="reference" not-null="true" />
            </many-to-one>
            <many-to-one name="commandes" class="Commandes" fetch="select">
                <column name="numcom" not-null="true" />
            </many-to-one>
            <property name="qte" type="java.lang.Integer">
                <column name="qte" />
            </property>
        </class>
    </hibernate-mapping>
    et le fichier hibernate.cfg.xml :

    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-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     
    <!-- Generated by MyEclipse Hibernate Tools. -->
    <hibernate-configuration>
     
    	<session-factory>
    		<property name="connection.username">khalil</property>
    		<property name="connection.url">jdbc:microsoft:sqlserver://localhost:1433</property>
    		<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
    		<property name="myeclipse.connection.profile">BaseCommandes</property>
    		<property name="connection.password">password</property>
    		<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
     
    		<mapping resource="Produits.hbm.xml" />
    		<mapping resource="Commandes.hbm.xml" />
    		<mapping resource="DetailCommandes.hbm.xml" />
    		<mapping resource="Clients.hbm.xml" />
     
    	</session-factory>
     
    </hibernate-configuration>
    é merci d'avance.

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2008
    Messages : 26
    Par défaut
    Moi aussi j'ai le même pb. Qq'un aurait-il trouvé la solution ?

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

Discussions similaires

  1. Association references unmapped class
    Par thaundeadboss dans le forum Hibernate
    Réponses: 1
    Dernier message: 09/07/2009, 13h59
  2. Comment associer ces deux classes?
    Par velodrome dans le forum Diagrammes de Classes
    Réponses: 5
    Dernier message: 24/05/2007, 22h56
  3. Association entre deux classes en dotnet
    Par lulu3111 dans le forum C++/CLI
    Réponses: 4
    Dernier message: 18/04/2007, 21h15
  4. difficulté à représenter une association de 3 classes
    Par fanette dans le forum Diagrammes de Classes
    Réponses: 38
    Dernier message: 04/03/2007, 12h12
  5. [mapping] unmapped class
    Par mehdi_swatch dans le forum Hibernate
    Réponses: 18
    Dernier message: 10/05/2006, 17h17

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