We have enabled Hibernate Statistics in our webapplication and are looking for an explanation of the relationship between Sessions opened, closed, and the number of transactions.
Our app uses Session Beans with CMT, and all Hibernate activity occurs in DAOs used by the Session Beans.
We have some architecture factory code that developers use to create and decorate their instances of their business logic classes which are using the DAOs which closes the session on completion of the business method call (this was written prior to the auto session close and flush facility that was added in Hibernate 3.x). In one or two known cases we know where developers are not using this code we have Sessions that are being opened and never closed, but this is in a very limited number of areas.
The figures that we need an explanation of are the relationship between sessions opened, sessions closed and transactions.
We are seeing more Sessions opened than closed and transactions (these figures are from a couple of hours of system usage):
sessions opened=2600,
sessions closed=2585,
transactions=2585,
successful transactions=2563
Are there any cases where Sessions can be opened that are not part of a Transaction, and where the Sessions are not closed? Do these figures look normal?
The number closed matches the number of transactions, but there are 15 Sessions unaccounted for. Some of these may be due to developers bugs in their code that I already mentioned where they are not using the cleanup code, but in that case the number opened (and not closed) should match number of transactions, but this is not the case.
Any thoughts?
Here are the remainder of the stats output:
flushes=1676,connections obtained=2590,statements prepared=26218,statements closed=26218,second level cache puts=533,second level cache hits=1629,second level cache misses=200,entities loaded=16052,entities updated=869,entities inserted=1859,entities deleted=34,entities fetched=1610,collections loaded=9559,collections updated=424,collections removed=135,collections recreated=2556,collections fetched=9242,queries executed to database=9859,query cache puts=0,query cache hits=0,query cache misses=0,max query time=6494
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using: DB2 8.2.3
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: