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