I have exactly the same problem here.

On Feb 17, 1:05 am, Fabio Maulo <fabioma...@gmail.com> wrote:
> AFIR there isn't BR in Criteria API since 1.2.0 -> 2.0.0
>
> 2010/2/16 Gabriel Schenker <gnschen...@gmail.com>
>
>
>
> > Fabio, do you know of any breaking changes in the criteria query api
> > between release 2.1.0 and 2.1.2?
> > We have plenty of queries using the criteria api and I am wondering
> > whether we are having a problem now and have to reassess all of
> > them...
>
> > On Feb 15, 11:36 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> > > btw a HQL for fixed query is a perfect solution especially if wrote in
> > the
> > > mapping and accessed through named-query.
>
> > > 2010/2/16 Gabriel Schenker <gnschen...@gmail.com>
>
> > > > by the way: NHibernate 3.0 alpha (the trunk) shows the same behavior...
>
> > > > -Gabriel
>
> > > > On Mon, Feb 15, 2010 at 10:16 PM, Gabriel Schenker <
> > gnschen...@gmail.com>wrote:
>
> > > >> in our applications we have been using criteria queries with great
> > > >> success. Lately we upgraded NHibernate from version 2.1.0.1001 to
> > > >> 2.1.2.4000 (this is the version that Fluent NHibernate 1.0 GA is
> > > >> using).
>
> > > >> But now we have a problem. Some of our criteria queries do NOT work
> > > >> again. I was able to reproduce the error and it is an issue in the
> > > >> CriteriaQueryTranslator. The query that was previously working without
> > > >> any problems now throws the following exception:
>
> > > >> "System.ArgumentException: Could not find a matching criteria info
> > > >> provider to: b1.Identifier = b2.Identifier"
>
> > > >> my test class is defined as follows
>
> > > >>   public class Baz
> > > >>   {
> > > >>       public virtual int Id { get; set; }
> > > >>       public virtual string Identifier { get; set; }
> > > >>       public virtual string Name { get; set; }
> > > >>       public virtual Baz Parent { get; set; }
> > > >>   }
>
> > > >> the HQL which is working(!) looks like this
>
> > > >>           var hql = "select p1.Id " +
> > > >>                     "from Baz as p1 " +
> > > >>                     "where not exists (" +
> > > >>                     "         from Baz as p3" +
> > > >>                     "         where p1.Parent.Id = p3.Id" +
> > > >>                     "         and p3.Id = (select max(p2.Id)" +
> > > >>                     "                      from Baz as p2" +
> > > >>                     "                      where p2.Id = p1.Id)" +
> > > >>                     ")";
> > > >>           var query = session.CreateQuery(hql);
> > > >>           var ids = query.List<int>();
>
> > > >> and the criteria query which throws the exception is
>
> > > >>           var isLastInFamily = DetachedCriteria.For<Baz>("b2")
> > > >>               .SetProjection(Projections.Max("b2.Id"))
> > > >>               .Add(Restrictions.EqProperty("b1.Identifier",
> > > >> "b2.Identifier"));
>
> > > >>           var exclude = DetachedCriteria.For<Baz>("b3")
> > > >>               .Add(Restrictions.EqProperty("b3.Parent.Id", "b1.Id"))
> > > >>               .Add(Subqueries.PropertyEq("b3.Id", isLastInFamily))
> > > >>               .SetProjection(Projections.Property("b3.Id"));
>
> > > >>           var query = session.CreateCriteria(typeof(Baz), "b1")
> > > >>               .Add(Subqueries.NotExists(exclude))
> > > >>               .SetProjection(Projections.Property("b1.Id"));
>
> > > >>           var ids = query.List<int>();
>
> > > >> what is wrong with the above criteria query? Or is it a known bug of
> > > >> the CriteriaQueryTranslator?
> > > >> Any help is highly appreciated
>
> > > >> PS: the query generated by NHibernate when using HQL (for SQLite) is
>
> > > >> select baz0_.Id as col_0_0_
> > > >> from   "Baz" baz0_
> > > >> where  not (exists (select baz1_.Id
> > > >>                   from   "Baz" baz1_
> > > >>                   where  baz0_.Parent_id = baz1_.Id
> > > >>                          and baz1_.Id = (select max(baz2_.Id)
> > > >>                                          from   "Baz" baz2_
> > > >>                                          where  baz2_.Identifier =
> > > >> baz0_.Identifier)))
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > Groups
> > > >> "nhusers" group.
> > > >> To post to this group, send email to nhus...@googlegroups.com.
> > > >> To unsubscribe from this group, send email to
> > > >> nhusers+unsubscr...@googlegroups.com<nhusers%2bunsubscr...@googlegroups.com>
> > <nhusers%2bunsubscr...@googlegroups.com<nhusers%252bunsubscr...@googlegroups.com>
>
> > > >> .
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/nhusers?hl=en.
>
> > > >  --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to nhus...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > nhusers+unsubscr...@googlegroups.com<nhusers%2bunsubscr...@googlegroups.com>
> > <nhusers%2bunsubscr...@googlegroups.com<nhusers%252bunsubscr...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > --
> > > Fabio Maulo
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to nhus...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nhusers+unsubscr...@googlegroups.com<nhusers%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhus...@googlegroups.com.
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to