Bonjour,
J'ai un soucis lors de l'accès à certaines données de classes.
J'ai deux classes mapées sur ma database: "Command" qui est composé de "CommandLine".
Lors de l'ajout d'une "CommandLine" à la liste des "CommandLines" de l'objet "Command", je souhaiterai remonter vers le parent et reparcourir ses enfants:
Par exemple:
CommandLine cl = new CommandLine();
A l'initialisation d'une des propriétés par hibernate, j'appelle une fonction computePrice() où je fais:
1 2 3
| foreach( CommandLine cl in this.Command.CommandLines)
{
} |
this.Command est initialisé, mais malheureusement lors de l'obtention de this.Command.CommandLines, j'obtiens une erreur intitulée
illegal access to loading collection.
Je ne cherche pas à la modifier cette collection, seulement à la parcourir.
Je m'y prends peut-être mal, mais je ne vois pas comment faire autrement et rapidement.
Merci de votre aide !
Pour info, voici le mapping:
1 2 3 4
| <class name="CommandLine" table="[Merilink].[dbo].[commandline]">
...
<many-to-one name="Command" column="command_id" class="Command" foreign-key="FK_commandline_command" not-null="true"/>
.... |
1 2 3 4 5 6 7
| <class name="Command" table="[Merilink].[dbo].[command]">
...
<bag name="CommandLines" inverse="true">
<key column="command_id" foreign-key="FK_command_commandline"/>
<one-to-many class="CommandLine"/>
</bag>
.... |
Partager