在条件执行之前,从NHibernate条件获取SQL查询 [英] get SQL query from NHibernate criteria, before the criteria executes

查看:153
本文介绍了在条件执行之前,从NHibernate条件获取SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NHibernate条件,我需要从中获取SQL查询.我从此处.但是,我得到的查询中没有参数(它以'?'代替,就像在此处).同样,至少一件事不起作用是criteria.setMaxResults(n).

I have a NHibernate criteria, from which I need to get the SQL query. I tried the various methods from here. However, the query which I get does not have the parameters in it(it has a '?' in place of that, just like mentioned over here and here). Also, at least one thing that does not work is criteria.setMaxResults(n).

我也尝试了NHibernate拦截器.但是,我在OnPrepareStatement(sql)中获得的查询也没有参数.还有其他方法可以从条件中获取sql查询吗?

I also tried NHibernate interceptors. However, the query which I get in the OnPrepareStatement(sql) also does not have the parameters. Is there any other way of getting the sql query from the criteria?

PS:-首先创建该标准,是因为它可以轻松满足复杂的业务需求.但是,我需要导出数据,这通过标准确实非常慢.我正在尝试从条件中获取查询,然后从中进行bcp导出.

PS:- The criteria is created in the first place since its easier to work with them for complicated business needs. However, I need to do an export of data, which is awesomely slow through criteria. I am trying to get the query from the criteria, and then do a bcp export from that.

推荐答案

要亲自回答这个问题,我认为不可能获得带有所有参数的完整查询,因为这些参数到处都是添加的.另外,一些技术还存在其他问题,例如,在使用条件联接沃克的情况下,setMaxResults不起作用,并且可能会破坏nhibernate中的更改.

To answer the question myself, I think its not possible to get the complete query with all the parameters, as the parameters are added all over the place. Also, there are other problems also with a few techniques, like in the case of using criteria join walker, setMaxResults does not work, and is subject to breaking changes in nhibernate.

这篇关于在条件执行之前,从NHibernate条件获取SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆