Bonjour,

Premiers test sur nHibernate et déjà des soucis.
Je n'arrive pas à charger une collection (bag) contenu dans un objet quand je charge ce dernier.

je m'explique :

J'ai une relation many-to-many bidirectionnelle entre deux tables :
Voici les fichiers de mapping :

Batch.hbm.xml
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" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   namespace="Project.Entities"
                   assembly="Project">
 
  <!-- Mappings for class 'Batch' -->
  <class name="Batch" table="Batch" lazy="false">
 
    <!-- Identity mapping -->
    <id name="IdBatch" type="System.Int32" unsaved-value="null">
      <column name="IdBatch" />
      <generator class="native" /> 
    </id>
 
    <!-- Simple mappings -->
    <property name="Name" />
 
    <!-- Many-to-many mapping: Action     -->
    <bag name="Action" table="BatchAction" cascade="all" lazy="false">
      <key column ="IdBatch" />
      <many-to-many class="Action" column="IdAction" />
    </bag>
  </class>
 
</hibernate-mapping>
Action.hbm.xml
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
38
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   namespace="Project.Entities"
                   assembly="Project">
 
  <!-- Mappings for class 'Action' -->
  <class name="Action" table="Action" lazy="false">
 
    <!-- Identity mapping -->
    <id name="IdAction" type="System.Int32" unsaved-value="null">
      <column name="IdAction" />
      <generator class="native" />
    </id>
 
    <!-- Simple mappings -->
    <property name="Name" />
 
    <!-- Simple mappings -->
    <property name="CreateDate" />
 
    <!-- Simple mappings -->
    <property name="Localisation" />
 
    <!-- Simple mappings -->
    <property name="Category" />
 
    <!-- Simple mappings -->
    <property name="Constraints" />
 
    <!-- Many-to-many mapping: Batch -->
    <bag name="Batchs" table="BatchAction" cascade="none" lazy="false">
      <key column ="IdAction" />
      <many-to-many class="Batch" column="IdBatch" />
    </bag>
 
  </class>
 
</hibernate-mapping>
J'utilise le code suivant pour charger la liste de batch


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
listBatch=(List<Batch>)_session.CreateCriteria(typeof(Batch)).List<Batch>();
J'obtiens bien la liste des batch mais la liste des actions dans les batchs est vide alors que la base est correctement initialisée.

Je sèche un peu aussi un coup de main serait le bienvenu

Merci d'avance de votre aide.