0
votes

i have some question regard c3p0 + Hibernate

from what i read here : c3p0&hibernate configuration

it look like you have to set some parameter with specific hibernate-related name or it will be overrided by hibernate default value.The question is that if i want to configure another parameter , like autoCommitOnClose , can i configure it in hibernate.cfg.xml or i need to configure it in seperate c3p0 propery file?, and if i can configure it in hibernate.cfg.xml file, what hibernate configuration key name i must use(is hibernate.c3p0.autoCommitOnClose is the right name?)since from what i see you need to change c3p0 parameter name from c3p0.maxPoolSize to hibernate.c3p0.max_size in order for hibernate to figure it out corrrectly.

thx for your answer.

1

1 Answers

0
votes

in remotely recent versions of hibernate (since ~2006), you can set c3p0 properties as hibernate.c3p0.propertyName in your hibernate config. however, if any of the hibernate-specific property names are set, they will override any config using the c3p0-style names. (hibernate will emit a warning in the logs if both styles are set.)

so e.g. hibernate.c3p0.autoCommitOnClose should work. c3p0's docs should be updated to reflect this.

c3p0 DataSources dump their config to logs at INFO level on pool initialization. you can always verify that the configuration you think you are setting is correctly applied by checking the logs (or via JMX). Search your logs for the string "Initializing c3p0 pool"

good luck!