Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 990479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:57:12+00:00 2026-05-16T05:57:12+00:00

I am attempting to query entities with HQL in order to return a list

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:57:12+00:00Added an answer on May 16, 2026 at 5:57 am

    I managed to resolve this by doing the following.

    There is a composite key in the table being used as a primary key, I removed the composite key and added a single primary key column. This new mapping results in the correct entities being returned from the query.

    If anyone has any explanation as to why this would be the case please add some comments. Thanks.

     <class name="Fact" table="Fact">
    
          <id name="FactID">
            <generator class="guid"/>
          </id>
    
          <many-to-one name="MarketDimension" column="MarketID" class="MarketDimension"/>
          <many-to-one name="FactorDimension" column="FactorID" class="FactorDimension"/>      
    
    
          <property name="ReportMonth" />
          <property name="ReportYear" />
    
        </class>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to query a LDAP server to return a Directory Entry based
I am attempting to convert the following HQL query to Criteria. from SubportfolioAudit as
I am attempting to query ActiveDirectory via LDAP, but the query may contain spaces
I'm attempting to query an SSAS cube using MDX, I have a list of
I am attempting to write a MySQL query that will return element whose details
I am attempting to retrieve an entry from my datastore with this: query =
I'm attempting to write a query that will return The most recent AccountDate with
I'm attempting to modify a mySQL query (that works) to return a more specific
I'm attempting to build a query that will return all non duplicate (unique) records
I make use of generic views and I am attempting to query my MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.