nhibernate参数绑定顺序潜在的bug?

时间:2011-03-15 15:36:02

标签: nhibernate debugging linq-to-nhibernate

我正在使用最新的nhibernate 3,我的查询:

iqt = rps.Terminals.GetQuery().Where(x => x.NetProtocol.Id == 4);
var res = iqt.OrderBy(x => x.Attributes[124]).ToList(); 
//ITerminal have IDictionary<long,string>

当我查看日志文件时,我看到生成的sql:

SELECT terminal0_.ID       AS ID4_        ,
  terminal0_.ALIAS          AS ALIAS4_     ,
  terminal0_.TTYPE_ID       AS TTYPE3_4_   ,
  terminal0_.IP_ADDRESS     AS IP4_4_      ,
  terminal0_.STREET         AS STREET4_    ,
  terminal0_.LOCATION       AS LOCATION4_  ,
  terminal0_.MODEL_ID       AS MODEL7_4_   ,
  terminal0_.NODE_ID        AS NODE8_4_    ,
  terminal0_.NETPROTOCOL_ID AS NETPROTO9_4_,
  (SELECT (xml_desc(terminal0_.street,'UA'))
     FROM terminals
    WHERE terminals.id =terminal0_.Id
  ) AS formula1_,
  (SELECT (xml_desc(terminal0_.location,'UA'))
     FROM terminals
    WHERE terminals.id =terminal0_.Id
  ) AS formula2_,
  (SELECT (xml_desc(terminal_models.description,'EN'))
     FROM terminal_models
    WHERE terminal_models.id = terminal0_.MODEL_ID
  ) AS formula3_
   FROM TERMINALS terminal0_,
  TERM_ATTRIBUTES attributes1_
  WHERE terminal0_.ID        =attributes1_.TERM_ID
AND attributes1_.ATTR_ID     = :p0
AND terminal0_.NETPROTOCOL_ID=:p1 //-> bug here it bind p1 with 124 value but correct p0
ORDER BY attributes1_.VALUE ASC;

:p0 = 4 [Type: Int64 (0)],
:p1 = 124 [Type: Int64 (0)]

我认为nhibernate无法使用子选择正确解析参数绑定顺序。 是否有nhibernate大师或开发人员确认并说明如何修复它?

Tnaks很多

1 个答案:

答案 0 :(得分:1)

看起来确实很糟糕。

请在http://jira.nhforge.org

打开一个问题,包括一个小型复制项目或测试用例