0

I have problem with lazy loading in many-to-many. There is no exception and there are rows in database but lazy loading returns 0 rows. Do you know why?

MAPPING:

 <class name="Riesitel" table="riesitel" lazy="true" >
    <composite-id>
      <key-many-to-one lazy="false" name="os_udaje">
        <column name="os_cislo" sql-type="integer" not-null="true" />
      </key-many-to-one>

      <key-many-to-one lazy="false" name="projekt_etapa">
        <column name="rok" not-null="true" />
        <column name="id_projektu" not-null="true" />
        <column name="id_fakulty" not-null="true" />
      </key-many-to-one>
    </composite-id>

    <bag name="riesitel_rolas" inverse="true" cascade="none" table="riesitel_rola">
         <key>
           <column name="os_cislo"/>
           <column name="rok"/>
           <column name="id_projektu"/>
           <column name="id_fakulty"/>
         <!--   <column name="id_rola" sql-type="Char"/> -->
        </key>
      <many-to-many class="Rola_v_projekte">
        <column name="id_rola"/>
      </many-to-many>
    </bag>


  <class name="Rola_v_projekte" table="rola_v_projekte" lazy="true" >

    <id name="id_rola">
      <column name="id_rola" sql-type="integer" not-null="true" />
      <generator class="sequence">
        <param name="sequence">id_rola_seq</param>
      </generator>
    </id>

    <bag name="riesitel_rolas" inverse="true" cascade="none" table="riesitel_rola">
      <key>
        <column name="id_rola" />
      </key>
      <many-to-many class="Riesitel">
        <column name="os_cislo"/>
        <column name="rok"/>
        <column name="id_projektu"/>
        <column name="id_fakulty"/>
      </many-to-many>
    </bag>

DB model: enter image description here

Eduard Baraniak
  • 421
  • 1
  • 10
  • 31
  • Are you sure you are connecting to the database you think you are? Have you looked at the sql that nhibernate is using and actually run it against the database it is connecting to? – Cole W Feb 09 '12 at 23:24
  • 4
    Go download NHProf, this will definitely help yo see what is going on. – CrazyCoderz Feb 10 '12 at 15:15

1 Answers1

0

I do not kwnow exactly why.. but: i think it is bug in NHibernate.. When i change my databese to non-composite id and change mapping all start working regurely:

enter image description here

Eduard Baraniak
  • 421
  • 1
  • 10
  • 31