Hi,
I have a need to set a C3P0 property that is not included in the standard set of Hibernate properties.
I am using Hibernate with mySQL and dynamically created and configured databases. This makes it difficult to use configured datasources from the application server. DBCP also does not like this enviroment, failing to perform a schema export with an existing connection pool in use.
I am therefore using C3P0, which works well (so far) but for one flaw, C3P0 by default attempts to rollback any uncommitted transactions on connection close. Now, mySQL by default has autocommit turned on, so I cannot call commit on the connection (I get an exception if I do), and I am in a catch 22 situation.
The way out is to set C3P0's 'c3p0.autoCommitOnClose' property to true, which I have done in a hacked version of Hibernate on C3P0ConnectionProvider.java. The javadoc for com.mchange.v2.c3p0.PoolConfig describes this property in more detail. If I do this, everything works fine.
If I've missed anything, please let me know.
My request would be to add a hibernate property, say 'hibernate.c3p0.autocommit', to set the relevant property in C3P0's PoolConfig class.
Thanks
Craig
BTW, I also tried to use Proxool, but found that it is impossible to use the hibernate.proxool.* type properties, since specifying hibernate.connection.url will give you a DriverManagerConnectionProvider, but ProxoolConnectionProvider requires hibernate.connection.url if the configuration does not come from an external file. Changing the if/else order in ConnectionProviderFactory may be a good way to fix it.
|