Wednesday, April 1, 2009

HibernateException: connection proxy not usable after transaction completion

Problem:
Some DAO methods acquire connections by
getSession().connection()
before calling stored procedures. Then they close the connection explicitly with
JdbcUtils.closeConnection()
Then the application throws "HibernateException: connection proxy not usable after transaction completion" from time to time.

Solution:
As described in Hibernate API, "if the session is using aggressive collection release (as in a CMT environment), it is the application's responsibility to close the connection returned by this call. Otherwise, the application should not close the connection". So in this case, it is fixed by remving the code to close connections.

1 comment:

  1. What does it mean by using aggressive collection release?

    ReplyDelete