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 :

Problème accés aux POJO


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Juin 2004
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 143
    Par défaut Problème accés aux POJO
    Bonjour,

    J'ai beau retourner le problème dans tous les sens, rien à faire :

    J'ai une exception lors du dépoiement de monj appli ou dedans il y a
    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
     
    java.lang.ExceptionInInitializerError
    	at mgpat.datawarehouse.jdbc.ServiceHibernate.requeteUniqueObject(ServiceHibernate.java:45)
    	at mgpat.authentification.ServiceAuthentification.authentification(ServiceAuthentification.java:33)
    	at mgpat.authentification.EcompteAdhEtAdminTest.testSoumettre(EcompteAdhEtAdminTest.java:13)
    	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 junit.framework.TestCase.runTest(TestCase.java:154)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: java.lang.RuntimeException: 
    	*** EXCEPTION ***
     
    		-- Exception levée depuis [mgpat.datawarehouse.jdbc.HibernateUtil.creationSessionFactory()]
    	at mgpat.datawarehouse.jdbc.HibernateUtil.<clinit>(HibernateUtil.java:32)
    	... 21 more
    Caused by: org.hibernate.MappingException: Association references unmapped class: mgpat.espaceadherent.adherent.hibernate.Decompte
    	at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2344)
    	at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2618)
    	at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
    	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1012)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
    	at mgpat.datawarehouse.jdbc.HibernateUtil.<clinit>(HibernateUtil.java:29)
    	... 21 more
    C'est normal, puique ma classe Decompte n'est pas dans ce package :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    mgpat.espaceadherent.adherent.hibernate
    mais dans mgpat.espaceadherent.presta.hibernate.Decompte comme je l'ai bien défini le bon mapping dans mon hibernate.cfg.xml :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <mapping resource="mgpat/espaceadherent/presta/hibernate/Decompte.hbm.xml"/>
    et j'ai alloué ma relation comme suis dans le fichier des personnes :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <!--  Relation entre le décompte et les actes -->
    		 <set name="decomptes" lazy="false">
    		 	<key column="idpersonne" />
    		 	<one-to-many class="Decompte" />
    		 </set>
    Mon POJO étant bien la classe décompte.

    Je bloque total, une idée ?

  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
    Si le pojo n'est pas dans le même fichier de mapping, renseigne le nom de classe complète de Décompte dans ta relation One-to-many.

    Ainsi tu aurais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <!--  Relation entre le décompte et les actes -->
    <set name="decomptes" lazy="false">
    	<key column="idpersonne" />
    	<one-to-many class="mgpat.espaceadherent.adherent.hibernate.Decompte" />
    </set>
    Ca ira mieux ainsi

    Bon courage

  3. #3
    Membre confirmé
    Inscrit en
    Juin 2004
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 143
    Par défaut
    si si mon Pojo est dans le même fichier de mapping :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    <mapping resource="mgpat/authentification/EcompteAdh.hbm.xml"/>
    		<mapping resource="mgpat/authentification/EcompteAdmin.hbm.xml"/>
    		<mapping resource="mgpat/espaceadherent/adherent/hibernate/Personne.hbm.xml"/>
    		<mapping resource="mgpat/espaceadherent/adherent/hibernate/Rib.hbm.xml"/>
    		<mapping resource="mgpat/espaceadherent/adherent/hibernate/Groupe.hbm.xml"/>
    		<mapping resource="mgpat/espaceadherent/adherent/hibernate/ContratClient.hbm.xml"/>
    		<mapping resource="mgpat/espaceadherent/presta/hibernate/Decompte.hbm.xml"/>
    		<mapping resource="mgpat/espaceadherent/presta/hibernate/Acte.hbm.xml"/>
    J'ai bien Personne et Decompte dans le même fichier de mapping. Mais les deux classes ne sont pas dans le même package effectivement.
    Je pensais qu'avec le fichier de mapping, il ferait le lien automatiquement.

  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
    Quand je parlais de fichier de mapiping je parlais réellement de fichier physique.
    Là tu me signales qu'ils sont tous deux dans la même configuration de Session Factory certes (c'est bien normal sinon cherche pas, ca ne fonctionnerait jamais ), mais on voit bien un fichier physique Decompte.hbm.xml et un autre fichier Personne.hbm.xml.

    D'où la problématique... Hibernate n'accepte "Decompte " dans personne que si les deux objets sont situés dans le même fichier physique de mapping voire dans le même package également (avec l'attribut package rempli dans le tag hibernate-mapping). Si le cas ne se présente pas, préfère afficher le nom complet (et dans un sens, c'est tout de même beaucoup plus lisible de toujours mettre le nom complet pour éviter d'éventuelle ambiguité

  5. #5
    Membre confirmé
    Inscrit en
    Juin 2004
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 143
    Par défaut
    Ok, je comprend la démarche !
    Merci

  6. #6
    Membre confirmé
    Inscrit en
    Juin 2004
    Messages
    143
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 143
    Par défaut
    Bon ca marche cependant j'ai une autre exception

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    [mgpat.datawarehouse.jdbc.HibernateUtil.creationSessionFactory()]
    	at mgpat.datawarehouse.jdbc.HibernateUtil.<clinit>(HibernateUtil.java:32)
    	... 21 more
    Caused by: org.hibernate.MappingException: Could not determine type for: String, for columns: [org.hibernate.mapping.Column(tiers)]
    	at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
    	at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
    	at org.hibernate.mapping.Property.isValid(Property.java:185)
    	at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:395)
    	at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
    	at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
    	at mgpat.datawarehouse.jdbc.HibernateUtil.<clinit>(HibernateUtil.java:29)
    	... 21 more

Discussions similaires

  1. BufferedImage et accès plus direct aux pixels
    Par millie dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 09/01/2010, 10h40
  2. [XL-2003] Accès protégé conditionnel aux feuilles d'un même fichier
    Par rberniga dans le forum Excel
    Réponses: 3
    Dernier message: 28/08/2009, 12h06
  3. Réponses: 11
    Dernier message: 28/07/2009, 10h10
  4. Avantage des EJB par rapport aux POJO
    Par Baptiste Wicht dans le forum JPA
    Réponses: 6
    Dernier message: 13/03/2008, 10h58
  5. Accès des Applications aux fichiers de config
    Par TryExceptEnd dans le forum Windows XP
    Réponses: 5
    Dernier message: 09/10/2007, 14h45

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