i been trouble shooting this hibernate/oracle10g issue all day.. I can't seem to get any of the timeouts to work. I wrote a test case just to test out the different ways of setting these timeouts, but none really seem to work for me.. The query would continue to run pass the timeout value that I set..
I'm using a DriverManagerDataSource here because I'm running this testcase in Eclipse, just to prove out the timeout concept. In production we are using a container managed datasource.
Code:
private int txnTimeout = 10;
private int queryTimeout = 10;
try {
Transaction txn = sessionFactory.getCurrentSession().getTransaction();
txn.setTimeout(txnTimeout); // I tried setting the timeout here..
txn.begin();
List<Object[]> results = sessionFactory.getCurrentSession().createSQLQuery("I have a query that takes very long to return here :)")
.setTimeout(queryTimeout) // I tried setting the timeout here..
.setCacheable(false)
.list();
} finally {
sessionFactory.getCurrentSession().close();
}
Code:
<!-- Hibernate's Session Factory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.xxx.xxx.xxx" />
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.current_session_context_class=thread
hibernate.id.new_generator_mappings=true
hibernate.show_sql=false
hibernate.format_sql=false
hibernate.use_sql_comments=false
hibernate.connection.release_mode=after_transaction
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=30 <!-- i tried setting the timeout here also -->
hibernate.c3p0.max_statements=50
</value>
</property>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="xxxx" />
<property name="username" value="xxxx" />
<property name="password" value="xxxx" />
</bean
Any help on this topic will really be appreciated! Thanks in advance