nhibernate 参数绑定顺序潜在的错误?

发布于 2024-10-22 05:24:33 字数 1509 浏览 2 评论 0原文

我正在使用最新的 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 大师或开发人员来确认并说明如何修复它?

知道很多

i am using latest nhibernate 3, my query:

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

When i look to the log file i see generated 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)]

I think nhibernate could not correctly resolve parameters bind order with sub selects.
Is there nhibernate guru or developer to confirm it and say how to fix it?

Tnaks a lot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薆情海 2024-10-29 05:24:33

它看起来确实有越野车。

请在 http://jira.nhforge.org 上打开一个问题,包括小型复制项目或测试用例

It does look buggy.

Please open an issue including a small reproduction project or test case at http://jira.nhforge.org

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文