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 4614026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:38:18+00:00 2026-05-22T01:38:18+00:00

Hi I have the same code and the same hbms running on two different

  • 0

Hi
I have the same code and the same hbms running on two different machines each with nhibernate 3 (everything is on a source repository and the latest verions are checked out from there) and nhibernate generates different sql queries on each of the machines

SearchResult<Contact> searchResult = new SearchResult<Contact>();
            RepositoryLink<Contact> link = new RepositoryLink<Contact>();


                ICriteria icriteria = null;
                var clientCriteria = DetachedCriteria.For<Contact>("c")
                                        .CreateCriteria("ContactRoles","cr", NHibernate.SqlCommand.JoinType.InnerJoin)
                                        .CreateCriteria("AclRole", "ar" ,NHibernate.SqlCommand.JoinType.InnerJoin)
                                        .Add(Restrictions.Eq("ar.RoleName", RoleCode.Client));


            foreach (var keyValuePair in searchCriteria)
            {
                switch (keyValuePair.Key)
                {
                    case SearchClientCriterion.Branch:
                        clientCriteria.CreateCriteria("c.BuEntries", "be" , NHibernate.SqlCommand.JoinType.InnerJoin)
                            .CreateCriteria("be.BuLevel","bl", NHibernate.SqlCommand.JoinType.InnerJoin)
                            .Add(Restrictions.Eq("bl.LevelNo", keyValuePair.Value));
                        break;
                    case SearchClientCriterion.City:
                        clientCriteria.Add(Restrictions.Eq("c.City", keyValuePair.Value));
                        break;
                    case SearchClientCriterion.ClientID:
                        clientCriteria.Add(Restrictions.Eq("c.ID", keyValuePair.Value));
                        break;
                    case SearchClientCriterion.DOB:
                        break;
                    case SearchClientCriterion.FirstName:
                        clientCriteria.Add(Restrictions.Like("c.FirstName", keyValuePair.Value,MatchMode.Anywhere));
                        break;
                    case SearchClientCriterion.LastName:
                        clientCriteria.Add(Restrictions.Like("c.LastName", keyValuePair.Value, MatchMode.Anywhere));
                        break;
                    case SearchClientCriterion.State:
                        clientCriteria.Add(Restrictions.Eq("c.StateId", keyValuePair.Value));
                        break;
                }
            }

            if(buLevel > 0)
                clientCriteria.CreateCriteria("c.BuEntries", "be", NHibernate.SqlCommand.JoinType.InnerJoin)
                        .CreateCriteria("be.BuLevel", "bl", NHibernate.SqlCommand.JoinType.InnerJoin)
                        .Add(Restrictions.Eq("bl.LevelNo", buLevel));


            var clientCountCriteria = (ICriteria)clientCriteria.GetExecutableCriteria(link.Session).Clone();
            searchResult.Count = clientCountCriteria.SetProjection(Projections.CountDistinct("c.ID")).UniqueResult<int>();


            icriteria = clientCriteria.GetExecutableCriteria(link.Session);
            searchResult.Data = icriteria.SetFirstResult((pageIndex - 1) * pageSize).SetMaxResults(pageSize).List<Contact>();

this is the criteria
this generates:

SELECT count(distinct this_.contactkey) as y0_
FROM   [Contact] this_
       inner join [ContactRole] cr1_
         on this_.contactkey = cr1_.contactkey
       inner join [AclRole] ar2_
         on cr1_.rolekey = ar2_.rolekey
WHERE  ar2_.rolename = 'C' /* @p0 */
       and this_.firstname like '%alex%' /* @p1 */

on one machine and

SELECT count(distinct this_.contactkey) as y0_
FROM   [Contact] this_
       left outer join [ContactRole] contactrol1_
         on this_.contactkey = contactrol1_.contactkey
       left outer join [AclRole] aclrole2_
         on contactrol1_.rolekey = aclrole2_.rolekey
WHERE  this_.username like '%alex%' /* @p0 */
       and not (aclrole2_.rolename = 'C' /* @p1 */)

Does anyone know why this is?

  • 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-22T01:38:19+00:00Added an answer on May 22, 2026 at 1:38 am

    In the end I recreated the entire database. Deleted everything. Recreated it.
    Checked out everything again and now it worked.

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

Sidebar

Related Questions

I have the same code running against two different SharePoint installations, to iterate through
I have several servers running the same code but each handling specific messages (they
I need to have the same code logging to two different places in two
I have different urls that points to the same code www.url1.com www.url2.com I need
I have many different branches/checkouts of the same project code on my development machine.
I have threaded code where each thread needs to write to the same file.
In my code base I find that two modules have structures with the same
I have this same code at the end of each view to go to
I have an existing website that uses the same code base, but is deployed
I have a Full and Lite applications that were built from the same code.

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.