I'd try removing the commit from the finally case.. if that line drops an exception (and it CAN drop, as you dont handle the session.close()'s exception either!), you'll method will return with the exception and the session would NOT get closed. You wouldn't want to commit anyway if you have any errors.. a more correct approach could be handling it like this:
.. finally { if (session != null) { try { session.close(); // this can drop exceptions too! } catch (Exception e) { e.printStackTrace(); // or logger.error (e, e); or something } } }
Actually, the code I've posted is included in a larger try-catch block that logs any exception and I can assure you that there are none in my test cases. I agree that trying to do a commit is not a wise thing to do, I just put it there hoping that it might have something to do with cursors, then I forgot to remove it.
The stable number of cursors open can happen because the pooled connections.. but that's a wild guess in the mid of nothing :)
After some more tests, I concluded that it has to do with the fact that the default hibernate.properties file is configured for pooling statements. I have now switched to using Tomcat's own connection and no statement pooling and the cursors are always closed. But in the end, I'm not sure this is A Good Thing, pooling statements could be beneficial in performance terms, I was just worried that it was a bug in my code.
If there's someone else using Hibernate under Tomcat (Matt?) or other containers, I'd like to ask whether you're using the container's pooling implementation or Hibernate's and why.
Ugo
-- Ugo Cei - Consorzio di Bioingegneria e Informatica Medica P.le Volontari del Sangue, 2 - 27100 Pavia - Italy Phone: +39.0382.525100 - E-mail: [EMAIL PROTECTED]
------------------------------------------------------- This SF.net email is sponsored by: Scholarships for Techies! Can't afford IT training? All 2003 ictp students receive scholarships. Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more. www.ictp.com/training/sourceforge.asp _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel