Programmatically get at the generated SQL

2 views
Skip to first unread message

bstack

unread,
Nov 20, 2009, 4:37:06 AM11/20/09
to nhusers
All,

Is there an easy way to programmatically get at the generated SQL as
opposed to having to use show_sql or use log4net?

Cheers
Billy Stack

Fabio Maulo

unread,
Nov 20, 2009, 7:06:38 AM11/20/09
to nhu...@googlegroups.com
There is a method in IIterceptor.

2009/11/20 bstack <bs.s...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=.





--
Fabio Maulo

Dinesh

unread,
Nov 20, 2009, 6:56:23 AM11/20/09
to nhusers
You can have a look at the Code by Ayende (below link), where he
calculates the number of statements executed per request using an
Appender, while this still uses log4net, you will have programmatic
access to the generated sql.

http://github.com/ayende/rhino-tools/blob/master/commons/Rhino.Commons.NHibernate/HttpModules/EnsureMaxNumberOfQueriesPerRequestModule.cs

Regards
Dinesh

Fabio Maulo

unread,
Nov 20, 2009, 5:35:05 PM11/20/09
to nhu...@googlegroups.com
That is no more needed.
You can use Statistics.

2009/11/20 Dinesh <dinesh.ms@gmail.com>
--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=.





--
Fabio Maulo

bstack

unread,
Nov 25, 2009, 9:07:08 AM11/25/09
to nhusers
I was looking for the exact sql that is executed against the db.

I know of statistics but that does not give me generated sql, it gives
counts generally
With Interceptor.OnPrepareStatement() - this does not give you exact
sql that is executed (and logged by show_sql or log4net).

Ken Egozi

unread,
Nov 25, 2009, 9:09:14 AM11/25/09
to nhu...@googlegroups.com
use showSql, and set the setup your stream on top of Console.Out so you'd get showSql's output.


--

You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.





--
Ken Egozi.
http://www.kenegozi.com/blog
http://www.delver.com
http://www.musicglue.com
http://www.castleproject.org
http://www.idcc.co.il - הכנס הקהילתי הראשון למפתחי דוטנט - בואו בהמוניכם
Reply all
Reply to author
Forward
0 new messages