Hi there,
I'm gonna start a new application with Spring + Hibernate Annotation.
I'm trying to use the @Transactional annotation in a Service layer but it is not work. Probably it's a configuration problem, but I didn't figure out the problem. Below following some pieces of my applicationContext.xml
DataSource
SessionFactoryCode:<!-- DataSource --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> <property name="url" value="jdbc:hsqldb:hsql://localhost/XYZ" /> <property name="username" value="sa" /> <property name="password" value="" /> </bean>
*Note: I'm using AnnotationSessionFactoryBean instead LocalSessionFactoryBeanCode:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="annotatedClasses"> <list> <value>MyAnnotatedClass </value> </list> </property> </bean>
Transaction
Also, within the Service Layer, I've got the @Transaction annotation.Code:<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:annotation-driven transaction-manager="txManager"/>
When I try to call the SAVE() method from Hibernate, nothing happens. If I start/commit the transaction manually (through sessionFactory.session.beginTransaction) it works fine. Hence, I guess the Spring Transaction Manager is not being called.
Please, does anybody can help me?
Thanks in advice


Reply With Quote
