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 :

[hibernate][webapp]Utilisation des hbms entres deux packages


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Par défaut [hibernate][webapp]Utilisation des hbms entres deux packages
    Bonjour,

    Je suis novice avec Hibernate, et j'ai un petit soucis.
    Je developpe sous Eclipse, j'ai deux applications web, que j'exporte vers Tomcat.
    Dans la première application j'ai défini des fichiers hbms, et j'aimerai utiliser ces fichiers hbms dans la deuxième application.
    webapp1 :
    cassette.hbm
    titre.hbm

    webapp2 :
    location.hbm

    or au niveau de la base de donnée, la table LOCATION est relié à la table CASSETTE. Je ne souhaite pas recréer le fichier hbm et le POJO associé de CASSETTE dans le webapp2.
    Donc j'ai essayé de créer un lien vers le fichier de cassette dans le fichier de mapping de location, mais ça ne fonctionne pas...

    voici le fichier location.hbm :

    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
     
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
     
    <hibernate-mapping>
    <!-- 
        Created by the Middlegen Hibernate plugin 2.2
     
        http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
    -->
     
    <class 
        name=" org.sakaiproject.hollywoodlocation.model.Hollylocation" 
        table="HOLLYLOCATION"
        lazy="false"
    >
     
        <id
            name="idLocation"
            type="java.lang.Integer"
            column="ID_LOCATION"
        >
     
            <generator class="assigned" />
        </id>
     
        <property
            name="nomClient"
            type="java.lang.String"
            column="NOM_CLIENT"
            not-null="true"
            length="99"
        />
        <property
            name="commentaire"
            type="java.lang.String"
            column="COMMENTAIRE"
            length="99"
        />
     
        <!-- Associations -->
     
        <!-- bi-directional many-to-one association to Cassette -->
        <many-to-one
            name="cassette"
            class="org.sakaiproject.hollywoodrdf.model.Cassette"
            not-null="true"
        >
            <column name="CODE_PRODUIT" />
            <column name="NO_COPIE" />
        </many-to-one>
     
    </class>
    </hibernate-mapping>
    et voici l'erreur que tomcat génére lors de son démarrage :

    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
     
     
    [C:\tomcat-5.5.17\components\sakai-db-pack\WEB-INF\components.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: entity class not found:  org.sakaiproject.hollywoodlocation.model.Hollylocation
    org.hibernate.MappingException: entity class not found:  org.sakaiproject.hollywoodlocation.model.Hollylocation
    	at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
    	at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:166)
    	at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
    	at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:115)
    	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
    	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
    	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
    	....
    at org.apache.catalina.core.StandardService.start(StandardService.java:450)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
    Caused by: java.lang.ClassNotFoundException:  org/sakaiproject/hollywoodlocation/model/Hollylocation
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:141)
    	at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
    	at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
    	... 62 more

  2. #2
    Membre averti
    Inscrit en
    Octobre 2004
    Messages
    45
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 45
    Par défaut
    ton découpage projet semble un peu "bizarre"...
    Mais pour répondre à ta question, hibernate ne semble pas trouver ta classe POJO HollyLocation définit dans ton fichier de mapping.
    Cet objet se situe ou?
    Peut être dans ta webapp1, et là il faut que tu fasse une référence au projet webapp1 dans ton projet webapp2.
    Ou alors tu devras créer un jar de ton projet webapp1 que tu placeras dans le chemin de compilation de ton projet webapp2.

  3. #3
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Par défaut
    Hollylocation se trouve dans le projet webapp2. Et donc je comprend pas pourquoi il le trouve pas. Peut être parce que Hibernate ne l'interprete pas bien à cause du lien (foireux?) avec Cassette.hbm situé dans webapp1 ?

  4. #4
    Membre averti
    Inscrit en
    Octobre 2004
    Messages
    45
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 45
    Par défaut
    peut tu mettre le code de ta classe HollyLocation?

  5. #5
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Par défaut
    le voilà :

    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
     
    package org.sakaiproject.hollyloc.model;
     
    import java.io.Serializable;
    import org.sakaiproject.webapp1.Cassette;
     
     
    /** @author Hibernate CodeGenerator */
    public class Hollylocation implements Serializable {
     
        /** identifier field */
        private Long idLocation;
     
        /** persistent field */
        private String nomClient;
     
        /** nullable persistent field */
        private String commentaire;
     
        /** persistent field */
        private Cassette cassette;
     
        /** full constructor */
        public Hollylocation(Long idLocation, String nomClient, String commentaire, Cassette cassette) {
            this.idLocation = idLocation;
            this.nomClient = nomClient;
            this.commentaire = commentaire;
            this.cassette = cassette;
        }
     
        /** default constructor */
        public Hollylocation() {
        }
     
        /** minimal constructor */
        public Hollylocation(Long idLocation, String nomClient, Cassette cassette) {
            this.idLocation = idLocation;
            this.nomClient = nomClient;
            this.cassette = cassette;
        }
     
        public Long getIdLocation() {
            return this.idLocation;
        }
     
        public void setIdLocation(Long idLocation) {
            this.idLocation = idLocation;
        }
     
        public String getNomClient() {
            return this.nomClient;
        }
     
        public void setNomClient(String nomClient) {
            this.nomClient = nomClient;
        }
     
        public String getCommentaire() {
            return this.commentaire;
        }
     
        public void setCommentaire(String commentaire) {
            this.commentaire = commentaire;
        }
     
        public Cassette getCassette() {
            return this.cassette;
        }
     
        public void setCassette(Cassette cassette) {
            this.cassette = cassette;
        }
     
     
     
    }

  6. #6
    Membre averti
    Inscrit en
    Octobre 2004
    Messages
    45
    Détails du profil
    Informations forums :
    Inscription : Octobre 2004
    Messages : 45
    Par défaut
    Voilà ton problème :
    ta classe POJO est définit dans le package :
    org.sakaiproject.hollyloc.model

    alors que Hibernate cherche dans :
    org.sakaiproject.hollywoodlocation.model

Discussions similaires

  1. Changement Des données entre deux bases
    Par Chakib dans le forum Access
    Réponses: 4
    Dernier message: 28/01/2006, 10h59
  2. [ADO.Net][VB.NET] Comment copier des données entre deux BDD différentes ?
    Par maddog2032 dans le forum Accès aux données
    Réponses: 6
    Dernier message: 06/06/2005, 11h01
  3. comment faire des espaces entre deux liens ???
    Par baaps dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 24/03/2005, 09h53
  4. [TP] Echanger des données entre deux programmes
    Par ILIAS Raphaël dans le forum Turbo Pascal
    Réponses: 3
    Dernier message: 22/03/2005, 09h31
  5. Réponses: 7
    Dernier message: 30/12/2004, 12h01

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