0

I ran into a strange issue with NHibernate today. I am pretty sure that there's an explanation and solution for this. So here we go: I have isolated one query with the issue and the code looks as follows:

_session = _sessionFactory.OpenSession();
ITransaction _transaction = _session.BeginTransaction();

var result = _session.QueryOver<Employee>()
   .Where(x => x.uid == employeeuid)
   .SingleOrDefault();

_transaction.Commit();

The Employee object has some references etc., but I don't think this is important right now. UID is a string. What basically happens is that log4net tells me that the same query is executed three times:

SELECT <some columns...> FROM employer this_ WHERE this_.uid = <uid-string>

As you can see... a plain query. Can anyone give me a hint how to get rid of the query-overhead?

Regards, Martin

1 Answer 1

1

I would first back this up by seeing what is being queried on the database itself. To find out what the database is actualy doing either:-

  1. Run SQL profiler and profile the queries
  2. Download a trial version of NHProfiler and check on that. This is a great tool and well worth the money to purchase it if you find it helps for future issues.

Personally I am a little suspicious of the amount of log info that log4Net spews out.

Sign up to request clarification or add additional context in comments.

1 Comment

Lol, I didn't think of this possibility :-) Actually it was the case that logs were written multiple times. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.