Hibernate version:
2.1.8
Mapping documents:
This is a big application, and there are 22 of them. The problem isn't particular to any operation on any particular data object, so omitting them for brevity's sake.
Code between sessionFactory.openSession() and session.close():
Here's a brief example method (using the ThreadLocal HibernateUtil class)
Code:
public List getAllAuthors() throws FacadeException
{
try
{
Session session = HibernateUtil.currentSession();
Query allAuthorsQuery = session.createQuery("from AllAuthor as aa where aa.uni != '' order by aa.lastName asc");
return allAuthorsQuery.list();
}
catch (HibernateException e)
{
log.warn(e);
try
{
HibernateUtil.closeSession();
}
catch (HibernateException e2)
{
log.warn("Caught exception trying to close session.", e2);
}
throw new FacadeException(e);
}
}
Full stack trace of any exception that occurs:N/A
Name and version of the database you are using:MS SQL Server, jtds-0.9.1.jar
problem description:Our problem isn't with the functionality of Hibernate, it's that Hibernate, according to the DBA we're working with (our access to the db itself is limited), is creating locks in the table temp_db that remain for at least an hour and that interfere with her administration of the db. Apparently, according to her description, it seems that these locks are related to PreparedStatements somehow. We've attempted to address the solution by changing from DBCP to C3P0 and configuring it to not pool prepared statements:
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3p0.timeout">100</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<property name="hibernate.c3p0.validate">false</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.c3p0.max_statements">0</property>
We weren't initally having the trouble with the production version of the database, but it has arisen after a few months of the application being in production. We've heard no reports of any similar problems from the DBA of our ordinary database, which is DB2/Solaris. Any insight anyone could offer as far as resources that Hibernate may secure during normal operation that may create locks that prevent other operations on the database would be helpful.
Code: