After bouncing around trying to find what is happening, I'm back with
a bit more information about my issues...
I'm running an MVC app with Fluent NHibernate (NH 3.1). When compiled
in Debug mode, everything works splendidly. When compiled in Release
mode, NHibernate isn't working. My session is built by Structuremap,
which injects a ISessionFactory (Singleton) into an HttpModule that
opens a transaction OnBeginRequest, and commits / rolls back
OnEndRequest. Nothing really ground breaking here, and as I said, this
all works in Debug mode.
My repository takes in this session, and calls a simple
Session.Query<T>().Where(x => x.Email =
"email").SingleOrDefault().
It does a lot more than that of course, but that is the particular
query I hit FIRST on an executed request (getting a user to login). I
always get null back from this in Release mode, whereas I get the
right object in Debug mode.
THAT IS ALL SETUP FOR THIS.
I am running this through NHProfiler to figure out what's happening.
In Debug mode, I see the transaction open, all the SQL get executed,
and then the transaction closed. In Release mode, I see the
transaction open, and then it just closes without executing any SQL.
There is something I am doing that is causing NHibernate to not
execute any SQL when in Release mode, OR NHibernate only outputs the
information NH Profiler needs when in Debug mode (Though it DOES
output the transaction begin/end log...). Just in case, I turned on my
own log4net log and go this out of it:
DEBUG 2011-06-02 12:03:36,349 [16] SessionImpl - [session-
id=449a1286-ff0e-46af-a4cc-235877c723b7] opened session at timestamp:
634426130163, for session factory: [/a28575cbfee44a269368768a28d01c78]
DEBUG 2011-06-02 12:03:36,363 [16] AdoTransaction - Begin
(Unspecified)
DEBUG 2011-06-02 12:03:36,366 [16] iverConnectionProvider - Obtaining
IDbConnection from Driver
DEBUG 2011-06-02 12:03:36,373 [16] QueryPlanCache - located
HQL query plan in cache (.SingleOrDefault[Domain.Model.User]
(.Where[Domain.Model.User]
(NHibernate.Linq.NhQueryable`1[STEP.Domain.Model.User], Quote((x, ) =>
(String.op_Equality(x.Email, p1))), ), ))
DEBUG 2011-06-02 12:03:36,376 [16] QueryPlanCache - located
HQL query plan in cache (.SingleOrDefault[Domain.Model.User]
(.Where[Domain.Model.User]
(NHibernate.Linq.NhQueryable`1[STEP.Domain.Model.User], Quote((x, ) =>
(String.op_Equality(x.Email, p1))), ), ))
DEBUG 2011-06-02 12:03:36,378 [16] HQLQueryPlan -
find: .SingleOrDefault[STEP.Domain.Model.User]
(.Where[Domain.Model.User]
(NHibernate.Linq.NhQueryable`1[STEP.Domain.Model.User], Quote((x, ) =>
(String.op_Equality(x.Email, p1))), ), )
DEBUG 2011-06-02 12:03:36,379 [16] QueryParameters - named
parameters: {}
DEBUG 2011-06-02 12:03:36,382 [16] ControllerBase - Action:
Account.LogOn | Time(s): 0.011
DEBUG 2011-06-02 12:03:36,384 [16] ControllerBase -
ActionResult: Account.LogOn => RedirectToRouteResult | Time(s): 0
DEBUG 2011-06-02 12:03:36,385 [16] AdoTransaction - Start
Commit
DEBUG 2011-06-02 12:03:36,386 [16] SessionImpl - before
transaction completion
DEBUG 2011-06-02 12:03:36,388 [16] AdoTransaction -
IDbTransaction Committed
DEBUG 2011-06-02 12:03:36,389 [16] SessionImpl -
transaction completion
DEBUG 2011-06-02 12:03:36,390 [16] ConnectionManager -
aggressively releasing database connection
DEBUG 2011-06-02 12:03:36,391 [16] ConnectionProvider - Closing
connection
DEBUG 2011-06-02 12:03:36,392 [16] AdoTransaction -
IDbTransaction disposed.
DEBUG 2011-06-02 12:03:36,393 [16] SessionImpl - [session-
id=449a1286-ff0e-46af-a4cc-235877c723b7] running ISession.Dispose()
DEBUG 2011-06-02 12:03:36,394 [16] SessionImpl - [session-
id=449a1286-ff0e-46af-a4cc-235877c723b7] executing real Dispose(True)
DEBUG 2011-06-02 12:03:36,395 [16] SessionImpl - closing
session
DEBUG 2011-06-02 12:03:36,398 [16] AbstractBatcher - running
BatcherImpl.Dispose(true)
Again, it would seem that Nhibernate is either not spitting out any
logging info when in Release mode, or is simply not executing any of
it's queries. When my solution is compiled in debug mode I get
thousands more lines of log messages, so I assume NHibernate is not
outputting a lot of stuff when the calling solution is compiled in
Release mode...
Does anyone have any insights into what I may be doing wrong?
Connection String properties that only work in Debug mode for some
reason?
Or even better, a way to make NHibernate spit out the same info for
the Release mode vs Debug mode so I can compare what they are doing?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.