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 :

Fichier de mapping introuvable


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Juin 2005
    Messages
    120
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 120
    Par défaut Fichier de mapping introuvable
    Bonjour,

    J'utilise Hibernate Annotation 3.0 et je voudrais spécifier de faire une outer-join lors d'une recherche. Puisque visiblement ce n'est pas possible avec les annotations, je vais utiliser en plus, un fichier de mapping xml.

    Voici son contenu :
    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//EN"
    "hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="domain">
    	<class name="Client" table="client">
    		<id name="id"/>
    		<list 
    			name="comptes"
    			table="compte"
    			outer-join="true"
    		>
    			<key column="id_client"/>
    			<index column="id"/>
    			<one-to-many class="domain.Compte"/>
    		</list>
    	</class>
     
    	<class name="Compte" table="compte">
    		<id name="id"/>
    		<many-to-one name="client" class="domain.Client" column="id_client"/>
    	</class>
     
    </hibernate-mapping>
    J'ajoute le fichier ainsi dans la configuration :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    config.addFile("Client.hbm.xml");
    Mais voilà, quelque soit l'endroit où je place mon fichier .xml et mon fichier .dtd, j'obtients l'erreur suivante :

    org.hibernate.MappingException: Could not read mapping document from file: Client.hbm.xml
    at org.hibernate.cfg.Configuration.addFile(Configuration.java:279)
    at util.HibernateUtil.<clinit>(HibernateUtil.java:92)
    at dao.hibernate.HibernateDaoFactory.getClientDao(HibernateDaoFactory.java:109)
    at service.referentiel.impl.ClientServiceImpl.count(ClientServiceImpl.java:63)
    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:585)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:124)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:112)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at weblogic.ejb.container.injection.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:32)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:124)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:112)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
    at $Proxy79.count(Unknown Source)
    at service.referentiel.impl.ClientServiceImpl_3mmudc_ClientServiceImpl.count(ClientServiceImpl_3mmudc_ClientServiceImpl.java:266)
    at service.referentiel.impl.ClientServiceImpl_3mmudc_ClientServiceWrap.count(ClientServiceImpl_3mmudc_ClientServiceWrap.java:66)
    at managedBean.referentiel.client.RechercheClientBean.countClients(RechercheClientBean.java:249)
    at managedBean.referentiel.client.RechercheClientBean.rechercher(RechercheClientBean.java:152)
    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:585)
    at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
    at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
    at javax.faces.component.UICommand.broadcast(UICommand.java:106)
    at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
    at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:267)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3205)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1986)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1893)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1377)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Caused by: org.dom4j.DocumentException: Client.hbm.xml (Le fichier spécifié est introuvable) Nested exception: Client.hbm.xml (Le fichier spécifié est introuvable)
    at org.dom4j.io.SAXReader.read(SAXReader.java:266)
    at org.hibernate.cfg.Configuration.addFile(Configuration.java:270)
    ... 53 more


    Où dois-je placer les fichiers .xml et .dtd ?
    Le deux types de mapping (annotations et fichier) peuvent-ils être utilisés simultanément ?

    Merci d'avance

  2. #2
    Membre émérite Avatar de BizuR
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    688
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 688
    Par défaut
    Pour le fichier XML de mapping, ca semble étrange puisque tu utilises les annotations.... menfin le truc ici c'est que si tu mets
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    config.addFile("mapping.hbm.xml");
    La fichier soit etre a la racine de ton classpath.

    maintenant si tu mets ton fichier de mapping autre part, exemple dans le package com.mapping.hbm, alors tu devras mettre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    config.addFile("com/mapping/hbm/mapping.hbm.xml");
    Quant au fichier de configuration, si tu en as un, et bien il se met systématiquement à la racine de ton classpath

    Voila, en esperant que cette explication saura résoudre ton problème

  3. #3
    Membre confirmé
    Inscrit en
    Juin 2005
    Messages
    120
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 120
    Par défaut Déjà essayé
    J'ai essayé mais ca ne fonctionne pas.
    Quelque soit l'endroit ou je place le fichier, j'ai la même erreur.

    Qu'appelles-tu la racine du classpath :
    - le dossier ou se trouvent le dossier source des classes Java ?
    - autre chose ?

  4. #4
    Membre émérite Avatar de BizuR
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    688
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 688
    Par défaut
    Désolé pour l'absence, j'étais en week end prolongé.
    Oui, la racine du classpath est bien le dossier ou tu met tes sources.

    Maintenant je n'ai pas été voir si il est possible de cumuler les deux types d'utilisation (annotations et fichiers de mapping). D'ailleurs ma question est la suivante :

    Pourquoi utiliser les deux types alors qu'ils font la même chose ?!?

  5. #5
    Membre confirmé
    Inscrit en
    Juin 2005
    Messages
    120
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 120
    Par défaut Peut être que je ne connais pas tout
    Je t'explique mon problème :

    Un client est lié à plusiuers comptes (liste). Cette liste peut ne comporter aucuns éléments.
    Lors que j'effectue une recherche de tous les clients, les clients ayant une liste de comptes avec 0 éléments ne sont pas rapportés. En regardant le code source hibernate, j'ai pu remarqué qu'il effectue une jointure interne (inner join) et non externe. Donc je voudrais forcer la jointure externe. Ceci est possible grace au fichier de config mais je n'ai pas trouvé comment le faire avec les annotations.

    Voilà, donc si tu as une idée, elle est la bienvenue

  6. #6
    Membre émérite Avatar de BizuR
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    688
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 688

Discussions similaires

  1. fichier my.cnf introuvable?
    Par david06600 dans le forum Installation
    Réponses: 6
    Dernier message: 05/12/2011, 16h43
  2. Hibernate et RCP: fichier mapping introuvable
    Par sixmillespieds dans le forum Eclipse Platform
    Réponses: 2
    Dernier message: 11/06/2008, 15h01
  3. [Hibernate] Fichier de mapping introuvable
    Par babylone7 dans le forum Hibernate
    Réponses: 3
    Dernier message: 06/01/2006, 17h06
  4. [Hibernate] [Eclipse] Création du fichier de mapping
    Par Willy7901 dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 11/08/2005, 17h54
  5. [DEBUTANT]Le fichier spécifié est introuvable
    Par Battosaiii dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 04/04/2005, 16h36

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