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

  • SEARCH
  • Home
  • 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 494647
In Process

The Archive Base Latest Questions

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

update: After not getting anywhere with this, I noticed that when I pulled the

  • 0

update: After not getting anywhere with this, I noticed that when I pulled the queries out into two distinct criteria, the actual hydrated objects returned were correct, but the count query was returning the joined dataset.

So the question is: How do I use Projections.RowCount in conjunction with CriteriaUtil.DistinctRootEntity and a DetachedCriteria.

I have two entities that are linked
via a many to many – Tags and Posts.

For an admin screen, I would like to
return paged results, so I’m using a
multicriteria to pull back my objects,
as well as the counts:

var multiResults = session.CreateMultiCriteria()
    .Add(criteria.SetMaxResults(Top))
    .Add(clone.SetProjection(Projections.RowCount())).List();

One of the filters that I have on this
page is a DateLastUsed filter. Here, I
want to return a Tag only if it has an
associated post that that was posted
after a certain date.

criteria.CreateAlias("AssociatedPosts", "p");
var mostRecent = DetachedCriteria.For(typeof (Post),"p2").SetProjection(Property.ForName("CreatedDate").Max())
                .Add(Restrictions.EqProperty("p.id", "p2.id"));

criteria.Add(Subqueries.Le(postedAfterDate),

mostRecent));

This seems to return the correct data
set, but I’m returning a tag for
each post that it is associated
with
. The next step was to apply
criteria.SetResultTransformer(CriteriaUtil.DistinctRootEntity)
but this didn’t seem to resolve the
issue.

I saw these couple of links that
seemed to point towards a bug, but it
seems that its been fixed (we’re using
2.0.1.4000).

  • NH-1055 – Multi Criteria ignored Result Transformer
  • http://markmail.org/message/rp3qusnhwcdincfo

Any ideas? First time I’ve played with
MultiCriteria, so I could be doing
something else weird (the other
filters are trivial).

  • 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-13T05:30:57+00:00Added an answer on May 13, 2026 at 5:30 am

    After doing some further investigation, I stumbled upon this:

    http://floledermann.blogspot.com/2007/10/solving-hibernate-criterias-distinct.html

    The issue described is almost identical to the one I’m running into. The comments provide some good additional insight.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 402k
  • Answers 402k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer var Peek = 0; $('ul ul').each(function(){ $(this).children('li').each(function(i, e){ if($(e).outerWidth() >… May 15, 2026 at 4:57 am
  • Editorial Team
    Editorial Team added an answer If you really do have 6 variables numerically named like… May 15, 2026 at 4:57 am
  • Editorial Team
    Editorial Team added an answer Check your table definitions to ensure that the maximum size… May 15, 2026 at 4:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.