Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.0[/b]
[b]Mapping documents:[/b]
[b]Code between sessionFactory.openSession() and session.close():
/////////////////////////////--- query 1 ---////////////////////////
Session aSession = null;
//Transaction tx = null;
try
{
aSession = HibernateUtil.currentSession();
//tx = aSession.beginTransaction();
Query q = aSession.createQuery("FROM Customer c order by c.name");
out.println("SIZE1: " + q.list().size());
//tx.commit();
}
catch (Exception e)
{
//if (tx != null)
//tx.rollback();
}
finally
{
out.println("closing hibernate session...<br>");
HibernateUtil.closeSession();
if (aSession.isOpen())
out.println("ERROR : hibernate session still open !<br>");
}
/////////////////////////////--- end query 1 ---////////////////////////
/////////////////////////////--- query 2 ---////////////////////////
Session bSession = null;
//Transaction tx1 = null;
try
{
currSession = HibernateUtil.currentSession();
//tx1 = currSession.beginTransaction();
Query query = currSession.createQuery("FROM Customer c order by c.name");
//out.println("SIZE2: " + query.list().size());
//tx1.commit();
}
catch (Exception e)
{
//if (tx1 != null)
//tx1.rollback();
}
finally
{
out.println("closing hibernate session...<br>");
HibernateUtil.closeSession();
if (currSession.isOpen())
out.println("ERROR : hibernate session still open !<br>");
}
/////////////////////////////--- end query 2 ---////////////////////////
[/b]
[b]Full stack trace of any exception that occurs:[/b]
[b]Name and version of the database you are using:postgresql 8.0[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:[/b]
Hi, I would like to know if any database access requires a transaction. Am asking this because, when I execute the above 2 queries (WITHOUT ANY TRANSACTION) in one call, I found that there is an 'idle in transaction' in my postgresql log. As if the transaction has not been commited. But I did not start any transaction. Can anyone plese tell me what is causing this? An when I execute the same 2 queries but now I put transaction in each of them, there is no 'idle in transaction'. I don't undestand this. Am using Hibernate in a non-managed environment (using Tomcat).
Can anyone please explain me why I got this 'idle in transaction'
thanks in advance