I will select a n:m mapping with HQL, but HQL didn't create the correct query. The where part in the query isn't generated.
Is there a bug in the query parser?
createQuery(
" select ag from ag in AggregatedFigureBean.class"
+ " where ag.figures = ? ",
new Object[] { figure },
new Type[] { Hibernate.entity(AbstractFigureBean.class) });
The generated query is
select ag.id as id, ... from FIGURE ag, ref_aggregator_aggregated figures0_ where ag.discriminator='AG' and (()
Hibernate version: 2.1.7
Mapping documents:
Code:
<!-- Figures -->
<class name="AbstractFigureBean" table="FIGURE" discriminator-value="AF">
<id name="id" type="long" unsaved-value="-1">
<generator class="native" />
</id>
<discriminator column="discriminator" type="string" length="8"/>
<version column="version" name="version" type="long"/>
<many-to-one name="report" column="report_id" class="AbstractReportBean" not-null="true" foreign-key="FK_FIG_REP" index="IDX_FIG_REP" />
<many-to-one name="organisation" column="organisation_id" class="OrganisationBean" foreign-key="FK_FIG_ORG" index="IDX_FIG_ORG" />
<many-to-one name="summenzeile" column="summenzeile_id" class="SummenzeileBean" foreign-key="FK_FIG_SUMZ" index="IDX_FIG_SUMZ" />
<many-to-one name="projekt" column="projekt_id" class="ProjektBean" foreign-key="FK_FIG_PRJ" />
<property name="frozen" type="boolean" not-null="true" />
<property name="value" type="double" />
<property name="kommentar" type="string" length="1000" column="kommentar" />
<property name="column" column="columnnr" type="integer" />
<subclass name="CalculatedFigureBean" extends="AbstractFigureBean" discriminator-value="CF">
</subclass>
<subclass name="RKZFigureBean" extends="AbstractFigureBean" discriminator-value="RF">
</subclass>
<subclass name="SingleFigureBean" extends="AbstractFigureBean" discriminator-value="SF">
</subclass>
<subclass name="AggregatedFigureBean" extends="AbstractFigureBean" discriminator-value="AG">
<list name="figures" batch-size="20" cascade="save-update" table="ref_aggregator_aggregated">
<key column="aggregator_id" foreign-key="FK_AGGFIG_AGGTOR" />
<index column="position" ></index>
<many-to-many class="AbstractFigureBean" column="aggregated_id" outer-join="true" foreign-key="FK_AGGFIG_AGGTED" />
</list>
</subclass>
</class>
The generated SQL (show_sql=true):Hibernate: select ag.id as id, ... from FIGURE ag, ref_aggregator_aggregated figures0_ where ag.discriminator='AG' and (()
[/code]