From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-30 19:14:36
|
[ http://216.121.112.228/browse/NH-2213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo resolved NH-2213. ----------------------------- Resolution: Fixed Fix Version/s: 3.2.0Beta2 > CLONE -Wrong parameters order in IQuery with SetParameterList and Filter. SQL Server 2005 > ----------------------------------------------------------------------------------------- > > Key: NH-2213 > URL: http://216.121.112.228/browse/NH-2213 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 2.1.2.GA > Reporter: Stefan Gruendig > Priority: Major > Fix For: 3.2.0Beta2 > > > IQuery query = session.CreateQuery("SELECT e FROM Event e " + > " inner join fetch e.descriptions d " + > " WHERE (e.SendedBy in( :dev)) " + > " AND (e.Date >= :from) " + > " AND (e.Date <= :to)" + > " ORDER BY d.Value"); > List<Device> devices = new List<Device>(); > devices.Add(device); > query.SetParameterList("dev", devices); > query.SetDateTime("from", date); > query.SetDateTime("to", date.AddMonths(1)); > Generated query has wrong parameter order: > select event0_.ID as ID0_0_, descriptio1_.ID as ID2_1_, event0_.IDStrumento as IDStrume2_0_0_, event0_.Data as Data0_0_, descriptio1_.IDEvento as IDEvento2_1_, descriptio1_.Descrizione as Descrizi3_2_1_, descriptio1_.IDLingua as IDLingua2_1_, descriptio1_.IDEvento as IDEvento0__, descriptio1_.ID as ID0__ from tblEventi event0_ inner join tblDescrizioni descriptio1_ on event0_.ID=descriptio1_.IDEvento and @p0 = descriptio1_.IDLingua where > ((event0_.IDStrumento in(@p1))) AND ((event0_.Data>=@p2 )) AND ((event0_.Data<=@p3 )) > order by descriptio1_.Descrizione; > @p0 = 'it', > @p1 = '01/01/2000 0.00.00', <-- WRONG! should be 1 > @p2 = '01/02/2000 0.00.00', > @p3 = '1'<-- WRONG! should be 10 '01/01/2000 0.00.00' > query works if I change the order of SetParameter: > List<Device> devices = new List<Device>(); > devices.Add(device); > query.SetParameterList("dev", devices); > query.SetDateTime("from", date); > query.SetDateTime("to", date.AddMonths(1)); > Generated query has right parameter order: > select event0_.ID as ID0_0_, descriptio1_.ID as ID2_1_, event0_.IDStrumento as IDStrume2_0_0_, event0_.Data as Data0_0_, descriptio1_.IDEvento as IDEvento2_1_, descriptio1_.Descrizione as Descrizi3_2_1_, descriptio1_.IDLingua as IDLingua2_1_, descriptio1_.IDEvento as IDEvento0__, descriptio1_.ID as ID0__ from tblEventi event0_ inner join tblDescrizioni descriptio1_ on event0_.ID=descriptio1_.IDEvento and @p0 = descriptio1_.IDLingua > where ((event0_.Data>=@p1 ))AND((event0_.Data<=@p2 ))AND((event0_.IDStrumento in(@p3))) > order by descriptio1_.Descrizione; > @p0 = 'it', > @p1 = '01/01/2000 0.00.00', > @p2 = '01/02/2000 0.00.00', > @p3 = '2' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |