I am attempting to query entities with HQL in order to return a list of objects. The query returns the correct number of rows, but the first entry (ie the first row returned is duplicated across all entities). What could be the cause of this problem?
The HQL query is
using (ISession session = NHibernateHelper.OpenSession())
{
var query = session.CreateQuery(@"
select facts from Fact as facts
inner join facts.FactorDimension as facDim
inner join facts.MarketDimension as markDim
inner join facDim.TargetDimension as tarDim where
markDim.MarketID = :marketId
and tarDim.TargetID = :targetId
and facts.ReportYear = :untilReportYear
and facts.ReportMonth <= :untilReportMonth
and facts.ReportMonth >= 1
");
query.SetString("targetId", targetId.ToString());
query.SetString("marketId", marketId.ToString());
query.SetString("untilReportMonth", untilPeriod.Month.ToString());
query.SetString("untilReportYear", untilPeriod.Year.ToString());
return query.List<Fact>();
}
and the mapping file is
<class name="Fact" table="Fact">
<composite-id>
<key-many-to-one name="MarketDimension" column="MarketID"
class="MarketDimension"/>
<key-many-to-one name="FactorDimension" column="FactorID" class="FactorDimension"/>
</composite-id>
<property name="ReportMonth" />
<property name="ReportYear" />
</class>
Thanks.