Hi,
I have the series that contains a list of seriesColors,
and I have color that contains a list of seriesColors too.
I´m using the classes with lazy="true", like the following mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Codification.SeriesTO,TO"
table="cod_serie" lazy="true">
<id name="Id" column="id_serie">
<generator class="identity"/>
</id>
<property name="Name" column="no_serie"/>
<property name="Code" column="cd_serie"/>
<property name="Price" column="preco"/>
<bag name="SeriesColors" inverse="true" lazy="true">
<key column="id_serie"/>
<one-to-many class="Codification.SeriesColorTO, TO"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Codification.ColorTO,TO"
table="cod_cor" lazy="true">
<id name="Id" column="id_cor">
<generator class="identity"/>
</id>
<property name="Code" column="cd_cor"/>
<property name="Name" column="no_cor"/>
<property name="HexCode" column="cd_hex_cor"/>
<bag name="SeriesColors" inverse="true" lazy="true">
<key column="id_cor"/>
<one-to-many class="Codification.SeriesColorTO, TO"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Codification.SeriesColorTO,TO"
table="cod_serie_x_cor" lazy="true">
<composite-id>
<key-many-to-one name="Series" column="id_serie"
class="Codification.SeriesTO,TO"/>
<key-many-to-one name="Color" column="id_cor"
class="Codification.ColorTO,TO"/>
</composite-id>
<property name="Price" column="preco"/>
</class>
</hibernate-mapping>
When I try to use the session.Find with hql like:
[code]
FROM SeriesColorTO seriescolor
[code]
It doesn´t returns (return null) the object color and series within SeriesColor.
When I change the classes, removing the lazy=true, The method returns the objects
of composite-id. But I need to do with lazy=true, because the classes will be used
in others classes, and I need performance loading only the objects that I want.
I changed the hql to use inner join fetch, but it doesn´t returns too:
[code]
FROM SeriesColorTO seriescolor
INNER JOIN FETCH seriescolor.Series series
INNER JOIN FETCH seriescolor.Color color
[/code]
somebody knows about this?
thanks!!!!