[hibernate-dev] Using AS7 prepared Statement caching and Hibernate 4.0.0.Beta4 + 4.0.0.Beta5
Scott Marlow
smarlow at redhat.com
Thu Aug 4 15:41:55 EDT 2011
Let me add, that in theory, the AS7 prepared statement cache, should not
close the prepared statements while they are in use by Hibernate.
Currently in AS7, if the cache fills up, the statement should be removed
from the pool but not closed.
I still would like to understand why the prepared statement is getting
closed while its still being used.
On 08/04/2011 10:00 AM, Scott Marlow wrote:
> https://issues.jboss.org/browse/AS7-1461 reflects a problem reported by
> two users. One user reported, that in a transaction that included
> multiple different entities being created, that Hibernate is trying to
> use a closed prepared statement.
>
> My question at this point is, what would happen if the AS7 prepared
> statement cache were to close a prepared statement during a transaction.
>
> For example, assuming that the prepared statement cache was configured
> to a very low limit, like two. After two unique sql statements are in
> the prepared statement cache, when a third unique sql statement is
> created, one of the two cached statements will be closed. Could
> Hibernate be holding onto one of these cached prepared statements (for
> reuse in the transaction) that are closed?
>
> Example execution order from user report:
>
> 1. insert into ASSEMBLIES (NAME, A_ID) values (?, ?)
>
> 2. other sql statements are executed.
>
> 3. insert into ASSEMBLIES (NAME, A_ID) values (?, ?)
>
> 4. other sql statements are executed.
>
> 5. At this point, I believe that "insert into ASSEMBLIES (NAME, A_ID)
> values (?, ?)" could be aged out of the AS7 prepared statement cache.
>
> 6. "insert into ASSEMBLIES (NAME, A_ID) values (?, ?)" fails to execute
> because of error
> "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
> No operations allowed after statement closed"
>
> For my local testing, I'm using H2 and get error
> "org.h2.jdbc.JdbcSQLException: The object is already closed [90007-145]"
>
> Does/should Hibernate check the prepared statement to see if its have
> been closed before its reused in a transaction? Or should users disable
> the AS7 prepared statement cache (current workaround)?
>
> If Hibernate is currently checking if the prepared statement is closed
> before reusing it, I must of missed that code in my inspection.
>
> At this point, I'm still trying to find the root cause and answer the
> above question as well.
>
> Scott
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
More information about the hibernate-dev
mailing list