-->
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.  [ 1 post ] 
Author Message
 Post subject: [Hibernate2]one-to-many
PostPosted: Mon Nov 07, 2005 7:01 am 
Newbie

Joined: Mon Nov 07, 2005 6:00 am
Posts: 1
bonjour J'ai commencé à utiliser Hibernate depuis quelques jours et je suis confronté à un petit problème , J'ai une relation 1..n entre 2 classes
Uf et Local (Une Uf pouvant être composée de plusieurs locaux, un local n'étant rattachée qu'à une seule Uf).

Mapping classe Uf
Code:
<hibernate-mapping package="cz.inventaire.domaine">
   <class
      name="Uf"
      table="Uf"
   >
      <id
         name="CodeUf"
         type="string"
         column="codeUf"
      >
         <generator class="assigned"/>
      </id>

      <property
         name="Designation"
         column="designation"
         type="string"
         not-null="false"
         length="100"
      />
      <property
         name="Responsable"
         column="responsable"
         type="string"
         not-null="false"
         length="50"
      />

      <bag inverse="true" name="LocalSet">
         <key column="codeUf" />
         <one-to-many class="Local" />
      </bag>



   </class>
</hibernate-mapping>


Mapping classe Local


Code:
<hibernate-mapping package="cz.inventaire.domaine">
   <class
      name="Local"
      table="Local"
   >
      <id
         name="CodeLocal"
         type="string"
         column="codeLocal"
      >
         <generator class="assigned"/>
      </id>

      <property
         name="Designation"
         column="designation"
         type="string"
         not-null="false"
         length="100"
      />

      <many-to-one
         name="CodeUf"
         class="Uf"
         not-null="true"
      >
         <column name="codeUf"/>
      </many-to-one>
       
   </class>
</hibernate-mapping>

Code:
public abstract class BaseLocal  implements Serializable {

   public static String PROP_CODE_LOCAL = "CodeLocal";
   public static String PROP_DESIGNATION = "Designation";
   public static String PROP_CODE_UF = "CodeUf";


   private int hashCode = Integer.MIN_VALUE;

   // primary key
   private java.lang.String _codeLocal;

   // fields
   private java.lang.String _designation;

   // many to one
   private cz.inventaire.domaine.Uf   _codeUf;

   
      public cz.inventaire.domaine.Uf getCodeUf () {
      return this._codeUf;
   }

      public void setCodeUf (cz.inventaire.domaine.Uf _codeUf) {
      this._codeUf = _codeUf;
   }
....
...
...}

public class Local extends BaseLocal
{...
....
....}


Code:
public abstract class BaseUf  implements Serializable {

   public static String PROP_DESIGNATION = "Designation";
   public static String PROP_CODE_UF = "CodeUf";
   public static String PROP_RESPONSABLE = "Responsable";


   private int hashCode = Integer.MIN_VALUE;

   // primary key
   private java.lang.String _codeUf;

   // fields
   private java.lang.String _designation;
   private java.lang.String _responsable;

   // collections
   private java.util.Collection _localSet;
...
....
public class Uf extends BaseUf
{...
....
....}


je veut la liste de tout les locaux liés a une Uf donnée mais l'instruction uf1.getLocalSet(); ne donne rien.
Est ce que je doit modifier quelque chose dans les fichiers de mapping ?
voir http://www.developpez.net/forums/viewtopic.php?t=413593


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

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.