I have an plain simple java application that use spring 2.5.5 and hiberate 3.3.1.GA. In the other word it is not running in any container like tomcat or jboss.
I want to enable transaction control in the application by the use of annotation @Tranactional. However after many trial the application does not begin any transaction as I’d expected. (Check on the server side, sybase 12.5, using sp_transactions)
I have read the doco a few time and hopefully I did not miss anything.
I added <tx:annotation-driven transaction-manager="txManager" /> to the application context xml file that contains the bean that needs to take part in a transaction.
Can anyone suggest
1) how can I turn spring logging to find out how spring framework discovers and instrument the @Transactional java classes?
2) I am using org.springframework.orm.hibernate3.HibernateTransactionManager as a transaction manager. Is it correct?
3) Do I need to add any jar to enable this support?
Here is a partial listing of the relevant applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
default-lazy-init="false">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.sybase.jdbc3.jdbc.SybDriver</value>
</property>
<property name="url">
<value>${jdbc.connection.url}</value>
</property>
<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="maxWait">
<value>30000</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration
</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SybaseDialect
</prop>
<prop key="hibernate.jdbc.batch_size">
50
</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">
ehcache.xml
</prop>
<prop key="hibernate.cache.use_query_cache">
true
</prop>
<prop key="hibernate.cache.use_second_level_cache">
true
</prop>
</props>
</property>
</bean>
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
EDIT:
In case it is relevant (Spring @Transactional concurrency), I have use @Transactional liberally
1 Answer