-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Unable to set hibernate.c3p0.max_statements
PostPosted: Tue May 08, 2007 4:59 am 
Beginner
Beginner

Joined: Mon Apr 23, 2007 8:30 am
Posts: 27
Location: India
It looks like Hibernate is not able to set the hibernate.c3p0.max_statements property in my application. Here is my hibernateProperties from spring config

Code:
<property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.c3p0.min_size">10</prop>
            <prop key="hibernate.c3p0.max_size">50 </prop>
            <prop key="hibernate.c3p0.idle_test_period">300</prop>
            <prop key="hibernate.c3p0.timeout">0</prop>
            <prop key="hibernate.c3p0.max_statements">15</prop>
            <prop key="hibernate.c3p0.acquire_increment">3</prop>
         </props>
</property>



The spring datasource config is :-
Code:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <property name="driverClass" value="${jdbc.driverClassName}"/>
      <property name="jdbcUrl" value="${jdbc.url}"/>
      <property name="user" value="${jdbc.username}"/>
      <property name="password" value="${jdbc.password}"/>
      <property name="acquireRetryAttempts" value="3"/>
      <property name="maxStatementsPerConnection" value="5"/>
      <!-- <property name="maxStatements" value="15"/> -->   
</bean>


With maxStatements commented in datasource, I expect the hibernateProperties hibernate.c3p0.max_statements to be active. However the following log shows the Hibernate default value for max statements which is 0

2007-05-08 13:53:47,212 INFO [com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource] - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 3, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 17g3ycg7mtmnwdimi191y|1284fd4, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 17g3ycg7mtmnwdimi191y|1284fd4, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:oracle:thin:@localhost:1521:xxxx, lastAcquisitionFailureDefaultUser -> null, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 5, minPoolSize -> 3, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]


When maxStatements in datasource configuration is uncommented, the max statements are configured correctly to 15 as defined in the datasource.

From what i understand, some of the c3p0 properties must be explicitly mentioned in the hibernate config, to prevent from using hibernate defaults over the actual c3p0 properties. In this case, why is Hibernate not able to set hibernate.c3p0.max_statements? I am using Hibernate 3. Am I missing something?

Thanks,
Nik


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 08, 2007 9:23 am 
Beginner
Beginner

Joined: Mon Apr 23, 2007 8:30 am
Posts: 27
Location: India
Actually, it makes more sense to configure statement cache per connection, rather than globally. At this point I am just curios to know why the maxstatements hibernate property is not working for me.

Thanks,
Nik


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 4:06 pm 
Newbie

Joined: Fri Mar 03, 2006 4:13 pm
Posts: 4
I ran into a similar situation when I set Hibernate to use a JNDI DataSource. Suddenly it started using DatasourceConnectionProvider instead of C3P0ConnectionProvider. Hibernate's c3p0 defaults and hibernate.c3p0.* properties are only active when using C3P0ConnectionProvider. It is trivial to use c3p0 to pool connections from a DataSource, but I guess Hibernate just isn't written that way.

Most Spring users configure Hibernate using Spring's LocalSessionFactoryBean. If LocalSessionFactoryBean is provided with a DataSource then it configures Hibernate to use a Spring ConnectionProvider (LocalDataSourceConnectionProvider or TransactionAwareDataSourceConnectionProvider as appropriate). Therefore, similar to above, C3P0ConnectionProvider does not get used.

Note that the c3p0 default for max statements is also 0. The 0 you see is probably from that instead of Hibernate:
http://www.mchange.com/projects/c3p0/in ... Statements


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 2:25 am 
Beginner
Beginner

Joined: Mon Apr 23, 2007 8:30 am
Posts: 27
Location: India
<prop key="hibernate.c3p0.max_statements">15</prop> is a hibernate property for C3P0, which means that this will override the C3P0 default and should use the hibernate one, i.e max_statements must be 15. However, inspite of configuring this it does take any effect. The rest of the C3P0 properties which are configured as hibernate properties work well.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 17, 2007 10:09 pm 
Newbie

Joined: Fri Mar 03, 2006 4:13 pm
Posts: 4
nikhil78 wrote:
The rest of the C3P0 properties which are configured as hibernate properties work well.

Not according to your first post. Three other properties from the configuration you posted are being ignored:
><prop key="hibernate.c3p0.min_size">10</prop>
...
>minPoolSize -> 3

><prop key="hibernate.c3p0.max_size">50 </prop>
...
>maxPoolSize -> 15

><prop key="hibernate.c3p0.idle_test_period">300</prop>
...
>idleConnectionTestPeriod -> 0

The remaining two are inconclusive. You set them to the default values, so there would be no change either way. Defaults listed here:
http://www.mchange.com/projects/c3p0/in ... axIdleTime
http://www.mchange.com/projects/c3p0/in ... eIncrement


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.