These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: [DEBUTANT][RESOLU] mapping d'une collection
PostPosted: Thu Jun 28, 2007 10:55 am 
Newbie

Joined: Mon May 21, 2007 11:08 am
Posts: 2
Bonjour,

Est-ce que quelqu'un pourrait m'aider à résoudre le problème suivant :

J'ai le mapping suivant :
Code:
<?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 package="fr..." schema="SCHEMA">
   <class name="GenXXX" table="DOSSIERXXX">
      <id name="..." column="CREF">
         <generator class="native" />
      </id>
      <property name="..." type="string" column="C1" />
      (...)   
         
      <!-- Classes filles héritantes -->
      <joined-subclass name="SpecXXX" table="DOSSIERXXX2" extends="GenXXX" >
         <key column="CREF" />
         <property name="..." ... />
         (...)
         
         <!-- collection associee -->
         <set name="enfant" lazy="false" table="F...">
            <key column="CREF" />
            <one-to-many class="F..." />
         </set>
      </joined-subclass>
               
   </class>
</hibernate-mapping>


dans la classe héritante SpecXXX, j'ai un attribut privé de type HashSet sur lequel je dispose de trois méthodes :

Code:
(...)

private Set<F...> f = new HashSet<F...>();

(...)

   public Set<F...> getF...() {
      return f;
   }

   public void setF...(Set<F...> f) {
      this.f = f;
   }
   
   public void addF...(F... f) {
      this.f.add(f) ;
   }
   
(...)


Je sais que dans la table, j'ai deux occurrences de F... qui doivent me revenir. Le problème est que je ne récupère qu'une ligne ! Aurais-je oublié quelque chose ?

Merci à tous ceux qui se pencheront sur mon problème.


Last edited by dvanders_fr on Fri Jun 29, 2007 3:25 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 11:34 am 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
Verifie les methodes hashCode() et equals() de F


Top
 Profile  
 
 Post subject: [DEBUTANT] mapping d'une collection
PostPosted: Fri Jun 29, 2007 3:21 am 
Newbie

Joined: Mon May 21, 2007 11:08 am
Posts: 2
Bonjour,

J'ai trouvé la solution : en fait, il manquait une PRIMARY_KEY (UNIQUE) sur la table.

Merci pour vos réponses.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.