Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate 3.1, Release mode and SQL not getting executed
    primarykey
    data
    text
    <p><strong>Edit:</strong> The below information was the symptom that led me to the following tests. I downloaded, compiled, and ran all the tests for NHibernate under Release mode. They all work. I fired up NH Profiler and looked at the difference between the logs in Debug and Release. Release didn't appear to be executing any SQL besides the transaction open and close statements. Verified that fact with SQL profiler.</p> <p>So NHibernate can connect to the database and execute transaction begin / end statements ok, and I can connect and execute arbitrary SQL via the normal ADO methods as well, but NHibernate can NOT execute any other SQL under Release mode.</p> <p>My session is opened and closed at the beginning and end of each request via an HttpModule, which uses a SessionFactory singleton inside a UnitOfWork implementation which is cached in HttpContext by Structuremap. </p> <p>It all works wonderfully under Debug.</p> <p>Also, changing my calling code to make sure that the first called NHibernate method is a Load returns this to me:</p> <p><code>Unable to locate persister: Domain.Model.User</code></p> <p><strong>Edit 2:</strong> Here's the stack trace...</p> <pre><code>[HibernateException: Unable to locate persister: STEP.Domain.Model.User] NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultLoadEventListener.cs:58 NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:2466 NHibernate.Impl.SessionImpl.Load(String entityName, Object id) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1213 NHibernate.Impl.SessionImpl.Load(Type entityClass, Object id) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1242 NHibernate.Impl.SessionImpl.Load(Object id) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1166 STEP.Persistence.Repositories.RepositoryWithTypedId`2.Load(TId id) in C:\Projects\STEP Handbook Dev\src\STEP.Persistence\Repositories\Repository.cs:80 STEP.Website.Providers.STEPNHibernateMembershipProvider.ValidateUser(String username, String password) in C:\Projects\STEP Handbook Dev\src\STEP.Website\Providers\STEPNHibernateMembershipProvider.cs:490 STEP.Website.Controllers.AccountController.LogOn(LogOnViewModel model, String returnUrl) in C:\Projects\STEP Handbook Dev\src\STEP.Website\Controllers\AccountController.cs:759 lambda_method(Closure , ControllerBase , Object[] ) +179 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39 System.Web.Mvc.&lt;&gt;c__DisplayClass15.&lt;InvokeActionMethodWithFilters&gt;b__12() +129 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +785360 System.Web.Mvc.Controller.ExecuteCore() +159 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335 System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +62 System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +20 System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +54 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +371 </code></pre> <p>And the code that triggers this is just a simple Session.Load(id) call to NHibernate.</p> <p><strong>Original:</strong></p> <p>When running NHibernate 3.1, I am getting an "Index was out of range" exception, but only when compiling in Release mode. I'm calling NHibernate here:</p> <pre><code>var results = Session.Query&lt;User&gt;.Where(predicate); </code></pre> <p>Then right below this, I am checking to see how many get returned (As this is actually my FindOne() method in my repository, and I need to make sure I only get one back). So I am calling results.Count(), which is triggering the NHibernate query to execute.</p> <p>My stack trace shows that this is happening in NhQueryprovider.ExecuteQuery at the last line of the method (Which is "return results[0]"). The only thing I can get from this is that apparently NHibernate is getting an empty list back there (It shouldn't there should be at least one result returned here...) which is causing this. </p> <p>This COULD be a bug in the NHibernate.Linq stuff that hasn't been caught yet, as I believe that just went native to Nhibernate in 3.x... Anyone else see this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload