Uploaded image for project: 'NHibernate'
  1. NH-2016

Duplicate Association Path when creating multiple aliases

    Details

    • Type: Bug
    • Status: Open
    • Priority: Trivial
    • Resolution: Unresolved
    • Affects Version/s: 2.1.1.GA
    • Fix Version/s: 5.0.1
    • Component/s: Core
    • Labels:

      Description

      Hello All,
      This is a bug I have noticed on my current NHibernate project. I tried to search for it on this forum and don't know if it has been rectified as of yet or not. However, the explanation for this bug is provided here:
      http://derek-says.blogspot.com/2008/06/duplicate-association-path-bug-in.html

      I would like to know if there is a way using criteria API to create multiple aliases that point to the same table. I would highly appreciate it if you could share any information on the same.
      My criteria is pretty simple:

       LeadManager manager = new LeadManager();
      ISession mySession = manager.Session.GetISession();
      ICriteria criteria = mySession.CreateCriteria(typeof(Lead));
      criteria.SetProjection(Projections.Distinct(Projections.Property("Id")));
      criteria.Add(Expression.Eq("CustomerId", 950));
      criteria.CreateAlias("CandidateMember", "candidate");
      criteria.CreateAlias("candidate.ExtensionValues", "extensions");
      criteria.CreateAlias("extensions.ExtensionValueTypeMember", "extensionTypes");
      Conjunction c = new Conjunction();
      c.Add(Expression.Eq("extensionTypes.Id", 1));
      c.Add(Expression.In("extensions.ExtensionDatum", new object[] { 'A', 'B' }));
      criteria.Add(c);
      criteria.CreateAlias("candidate.ExtensionValues", "extensions1");
      criteria.CreateAlias("extensions1.ExtensionValueTypeMember", "extensionTypes1");
      Conjunction c1 = new Conjunction();
      c1.Add(Expression.Eq("extensionTypes.Id", 2));
      c1.Add(Expression.In("extensions.ExtensionDatum", new object[] { 'A', 'B', 'C', 'D' }));
      criteria.Add(c1);
      criteria.SetMaxResults(10);
      long[] leadIds = criteria.List<Int64>().ToArray();
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                amarwadi Anup Marwadi
              • Votes:
                10 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Who's Looking?