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