There were a lot of posts about collections not loading. I did check them and my problem is a bit different. Namely I have two column foreign key
Code:
<bag name="ToUserLessonWords" lazy="true">
<key>
<column name="lesson_id" />
<column name="user_id" />
</key>
<one-to-many class="hibernate.LessonWord,hibernate"></one-to-many>
</bag>
Here is destination entity
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="hibernate.LessonWord, hibernate" table="user_lesson_word">
<composite-id>
<key-property name="LessonId" column="lesson_id" type="System.Int32" />
<key-property name="UserId" column="user_id" type="System.Int32" />
<key-property name="Word" column="word" />
</composite-id>
<property name="Score" column="score"></property>
<property name="Attempts" column="attempts"></property>
<property name="ReverseAttempts" column="reverse_attempts"></property>
<property name="ReverseScore" column="reverse_score"></property>
</class>
</hibernate-mapping>
Generated SQL is OK
Code:
SELECT touserle0_.lesson_id as lesson_id__, touserle0_.user_id as user_id__, touserle0_.word as word__, touserle0_.lesson_id as lesson_id0_, touserle0_.user_id as user_id0_, touserle0_.word as word0_, touserle0_.reverse_attempts as reverse_6_0_, touserle0_.reverse_score as reverse_7_0_, touserle0_.score as score0_, touserle0_.attempts as attempts0_ FROM user_lesson_word touserle0_ WHERE touserle0_.lesson_id = ?p0 AND touserle0_.user_id = ?p1
and if used to select rows manually selects everything it should...
Collection remains empty however.
Here is the log
Code:
2005-06-14 13:08:39,088 [1672] DEBUG NHibernate.Loader.Loader [] <> - result set contains (possibly empty) collection: [hibernate.UserLesson.ToUserLessonWords#hibernate.UserLesson]
2005-06-14 13:08:39,088 [1672] INFO NHibernate.Impl.SessionImpl [] <> - uninitialized collection: initializing
2005-06-14 13:08:39,098 [1672] DEBUG NHibernate.Loader.Loader [] <> - processing result set
2005-06-14 13:08:39,098 [1672] DEBUG NHibernate.Loader.Loader [] <> - done processing result set (0 rows)
2005-06-14 13:08:39,098 [1672] DEBUG NHibernate.Loader.Loader [] <> - total objects hydrated: 0
2005-06-14 13:08:39,098 [1672] DEBUG NHibernate.Impl.SessionImpl [] <> - 1 collections were found in result set
2005-06-14 13:08:39,108 [1672] DEBUG NHibernate.Impl.SessionImpl [] <> - collection fully initialized: [hibernate.UserLesson.ToUserLessonWords#hibernate.UserLesson]
2005-06-14 13:08:39,118 [1672] DEBUG NHibernate.Impl.SessionImpl [] <> - 1 collections initialized
Any ideas what I am doing wrong?