From: NHibernate J. <mik...@us...> - 2006-11-01 19:14:32
|
[ http://jira.nhibernate.org/browse/NH-787?page=all ] Sergey Koshcheyev closed NH-787: -------------------------------- Resolution: Not an Issue Use "in (:parameter)". > IQuery.SetParameterList() - Malformed SQL > ----------------------------------------- > > Key: NH-787 > URL: http://jira.nhibernate.org/browse/NH-787 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.0.2 > Reporter: Steve Guidi > > I have discovered the following issue using nHibernate 1.0.2 with SQL Server 2000. > IList mappedObjectCollection = session.CreateCriteria(typeof(T)).List(); > session.CreateQuery("from T t where t in :objectsToLoad") > .SetParameterList("objectsToLoad", mappedObjectCollection, NHibernateUtil.Entity(typeof(T))) > .List(); > The mapping of the T class uses the GUID generator for its primary key, mapped to a property called "Key". When I execute the code with the SetParameterList directive, I notice that the generated SQL is incorrect (see below). I've replaced the selected columns of the T with '*' class for brevity. > The generated SQL (show_sql=true): > exec sp_executesql > N'select * from T t0_ where (t0_.Key in @p0 , @p1 , @p2)', > N'@p0 uniqueidentifier,@p1 uniqueidentifier,@p2 uniqueidentifier', > @p0 = 'F44B4D98-311C-4800-B600-9C7499C7AF22', > @p1 = '36FFAC14-61F7-4673-985C-7DF8BE21D9AC', > @p2 = 'A7EBCDB0-36C2-48D3-B8DD-9CE56568BD56' > Note the first parenthesis in the where clause -- it is in the wrong location. The parenthesis should be between the 'in' directive and the first parameter. > I initially reported this issue via the nHibernate Community forum: http://forum.hibernate.org/viewtopic.php?t=966687. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |