#Glimpse for NHibernate
Glimpse for NHibernate is a Glimpse plugin that adds SQL statements generated by NHibernate to the Glimpse UI.
Yes, on NuGet you can find 2 NHibernate plugins for Glimpse.
- Glimpse.NHibernate by me
- NHibernate.Glimpse by ranzlee
The plugin I created doesn't add a new tab to the Glimpse UI, it integrates with the existing SQL tab by leveraging the Glimpse.ADO package. By reusing the Glimpse.ADO infrastructure all NHibernate statements are automatically shown on the Glimpse Timeline tab as well.
If you're interested in Ranzlee's package, you can read all about it here.
Basically all versions of NHibernate you can find on this page are supported, we don't support the alpha or beta versions. Only the ones that end with GA or SPx.
The current list of supported versions is:
- 4.1.1.GA
- 4.1.0.GA
- 4.0.4.GA
- 4.0.3.GA
- 4.0.2.GA
- 4.0.1.GA
- 4.0.0.GA
- 3.4.1.GA
- 3.4.0.GA
- 3.3.5.GA
- 3.3.4.GA
- 3.3.3.SP1
- 3.3.3.GA
- 3.3.2.GA
- 3.3.1.GA
- 3.3.0.GA
- 3.2.0.GA
- 3.1.0.GA
- 3.0.0.GA
- 2.1.2.GA
- 2.1.0.GA
- 2.0.1.GA
- 1.2.1.GA
- From NuGet:
Install-Package Glimpse.NHibernate
Nope, all you have to do is reference the assembly. The plugin then automatically injects itself into your code.
The Glimpse SQL tab is disabled
The SQL tab remains disabled as long as there's nothing to show. This means that no SQL statements were captured. You can solve this by initializing your NHibernate session factory at application startup, before the Glimpse.NHibernate package injects itself into your code.
Unable to cast object of type 'Glimpse.Ado.AlternateType.GlimpseDbCommand' to type 'System.Data.SqlClient.SqlCommand'
at NHibernate.AdoNet.SqlClientBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session)
at NHibernate.Action.EntityUpdateAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
at NHibernate.Impl.SessionImpl.Flush()
Most of the time this happend when you're executing and insert/update/delete statement against a SQL Server database. The exception occurs in the SqlClientBatchingBatcher which tries to cast the GlimpseDbCommand to a SqlCommand. At the moment the only way to solve this is to disable batching of SQL commands (you should only do this for debugging purposes).
var configuration = new Configuration()
.AddProperties(new Dictionary<string, string>
{
{ Environment.BatchStrategy, typeof(NonBatchingBatcherFactory).FullName }
};