我遇到多对多延迟加载的问题。没有异常,数据库中有行,但延迟加载返回0行。你知道为什么吗?
映射:
<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>
数据库模型:
答案 0 :(得分:0)
我并不知道为什么......但是:我认为这是NHibernate中的错误..当我将我的数据库更改为非复合id并更改映射时,所有开始工作都是肯定的: