]
Sergey Proskurnya commented on HHH-2694:
----------------------------------------
This is definitely a Hibernate issue.
Looking into code:
SessionFactoryImpl.close() {
...
try {
settings.getConnectionProvider().close();
}
finally {
SessionFactoryObjectFactory.removeInstance(uuid, name, properties);
}
if ( settings.isAutoDropSchema() ) {
schemaExport.drop( false, true );
}
}
The C3p0 (and proxool) connection providers are not able to create/give a new connection
after calling ConnectionProvider.close() method
because they have honest close(), which release all occupied resources.
As opposed to them, the DatasourceConnectionProvider and "native" Hibernate
DriverManagerConnectionProvider don't really close,
making possible to acquire a new Connection after calling ConnectionProvider .close()
method.
The DatasourceConnectionProvider couldn't be closed by Hibernate, because there is no
way to close external supplied DataSource,
because luck of close() method in javax.sql.DataSource interface.
And DriverManagerConnectionProvider simply does not have a "closed" state, thus,
creating a new Connection on demand regadless
of calling DriverManagerConnectionProvider.close().
Experience the same bug with:
hibernate core 3.2.6 and c3p0 configured via Hibernate (not as external DataSource).
create-drop with c3p0 causes SQLException
-----------------------------------------
Key: HHH-2694
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2694
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1
Environment: hibernate-entitymanager 3.2.1.ga, c3p0 0.9.0, and postgreSQL 8.1.8
or hsqldb 1.8.7
Reporter: Chris Redekop
Attachments: c3p0Test.tar.gz
In the attached test application, an EntityManagerFactory is created and then closed.
Closing the EMF causes line 801 of org.hibernate.impl.SessionFactoryImpl to call
getConnectionProvider().close(), which eventually results in c3p0's PooledDataSource
being closed.
Line 808 of org.hibernate.impl.SessionFactoryImpl the calls schemaExport.drop(), which
attempts to acquire a connection from the data source and causes the following
SQLException.
java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@fced4 [
connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@9505f [
acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000,
autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure
-> false, checkoutTimeout -> 0, connectionTesterClassName ->
com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null,
forceIgnoreUnresolvedTransactions -> false, identityToken -> 9505f,
idleConnectionTestPeriod -> 100, initialPoolSize -> 10, maxIdleTime -> 100,
maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0,
minPoolSize -> 10, nestedDataSource ->
com.mchange.v2.c3p0.DriverManagerDataSource@80cac9 [ description -> null, driverClass
-> null, factoryClassLocation -> null, identityToken -> 80cac9, jdbcUrl ->
jdbc:hsqldb:., properties -> {user=******, password=******, autocommit=true,
release_mode=auto} ], preferredTestQuery -> null, propertyCycle -> 300,
testConnectionOnCheckin -> false, testConnectionOnCheckout -> false,
usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null,
identityToken -> fced4, numHelperThreads -> 3 ] has been closed() -- you can no
longer use it.
This exception is swallowed so it does not cause a test error, but it does appear in the
console output.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: