arf.... I've figured it out.

the key column of my collection should be

<key column="PostID"/>

and not

<key column="CommentID" />

I've mixed up primary key and foreign key.

On 1 avr, 14:39, graphicsxp <[email protected]> wrote:
> Hi,
>
> I have an entity Post which holds a collection of entities Comments.
>
> It seems as when I request the Comments, only the first one in the
> collection is loaded. Could it be an issue with my mapping ?
>
> I've noticed that for property thePublication , the type changes from
> Publication to PublicationProxy (as expected) but for the property
> Comments, the type remains
> NHibernate.Collection.Generic.PersistentGenericBag<Metrica.CommentPost>.
>
> Post :
>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
>   <class name="Metrica.Post, Metrica" table="Post" lazy="true"
> discriminator-value="POST" abstract="true">
>     <id name="Id" column="PostID">
>       <generator class="native"/>
>     </id>
>
>     <discriminator column="Type" type="string" />
>
>    <many-to-one class="Metrica.Publication,Metrica"
> name="thePublication" cascade="none" column="PublicationID" />
>
>     <bag  name="Comments" inverse="true" cascade="all" lazy="true">
>       <key column="CommentID" />
>       <one-to-many class="Metrica.CommentPost, Metrica" />
>     </bag>
>
>   </class>
>
> CommentPost :
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
>   <class name="Metrica.CommentPost, Metrica" table="Comment"
> lazy="true" discriminator-value="COMMENT"
> proxy="Metrica.CommentPost,Metrica" >
>
>     <id name="Id" column="CommentID">
>       <generator class="native"/>
>     </id>
>
>     <discriminator column="Type" type="string" />
>
>     <many-to-one name="thePost" cascade="none" column="PostID" not-
> null="true" />
>
>   </class>
> </hibernate-mapping>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to