I'm trying to set up an application with declarative transactions using Spring 2 and IBatis and am having no luck. I'd appreciate it if one of the Spring gurus on this board can spot how I screwed up.
Here's my Spring config file:
and here's my interface TaskService.java:Code:<?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:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop" 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.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"> <bean id="taskService" class="com.corp.app.todolistportlet.database.TaskServiceImpl" > <property name="sqlMap"><ref local="sqlMapClient" /></property> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <!-- all methods use the default transaction settings --> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="allDatabaseServiceMethods" expression="execution(* com.corp.app.todolistportlet.database.TaskService.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="allDatabaseServiceMethods"/> </aop:config> <jee:jndi-lookup id="dataSource" jndi-name="jdbc/todo"></jee:jndi-lookup> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="com/corp/app/todolistportlet/database/sqlMap-config.xml"/> <property name="dataSource" ref="dataSource"/> </bean> </beans>
and my implementation. I'm not using Spring's SqlMapDAOSupport class because I need my service class to extend a different super class:Code:package com.corp.app.todolistportlet.database; import java.util.List; public interface TaskService { List getTasks(); }
When this code is run, the query runs fine, but there's no sign of it getting wrapped by a transaction. My understanding is that the expressionCode:package com.corp.app.todolistportlet.database; import java.sql.SQLException; import java.util.List; import org.springframework.orm.ibatis.SqlMapClientCallback; public class TaskServiceImpl extends TodoListPortletDatabaseService implements TaskService { public List getTasks() { return sqlMap.queryForList("getTasks", null); } }
should cause each method in the TaskService interface to be wrapped in a transaction. Here's the Spring DEBUG level log output:execution(* com.corp.app.todolistportlet.database.TaskService. *(..))
It's really starting to frustrate me that I can't figure this out, so any help would be greatly appreciated. Thanks in advance!Code:[2007-07-02 09:30:33,613] DEBUG (org.springframework.orm.ibatis.SqlMapClientTemplate) - Opened SqlMapSession [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@16622e6] for iBATIS operation [2007-07-02 09:30:33,613] DEBUG (org.springframework.jdbc.datasource.DataSourceUtils) - Fetching JDBC Connection from DataSource [2007-07-02 09:30:33,613] DEBUG (org.springframework.jdbc.datasource.DataSourceUtils) - Fetching JDBC Connection from DataSource [2007-07-02 09:30:33,633] DEBUG (java.sql.Connection) - {conn-100000} Connection [2007-07-02 09:30:33,633] DEBUG (org.springframework.orm.ibatis.SqlMapClientTemplate) - Obtained JDBC Connection [weblogic.jdbc.wrapper.PoolConnection_oracle_jdbc_driver_OracleConnection@30] for iBATIS operation [2007-07-02 09:30:33,644] DEBUG (java.sql.PreparedStatement) - {pstm-100001} PreparedStatement: SELECT * FROM tasks [2007-07-02 09:30:33,644] DEBUG (java.sql.PreparedStatement) - {pstm-100001} Parameters: [] [2007-07-02 09:30:33,644] DEBUG (java.sql.PreparedStatement) - {pstm-100001} Types: [] [2007-07-02 09:30:33,654] DEBUG (java.sql.ResultSet) - {rset-100002} ResultSet [2007-07-02 09:30:33,654] DEBUG (java.sql.ResultSet) - {rset-100002} Header: [task_id, task_name, description, date_created] [2007-07-02 09:30:33,654] DEBUG (java.sql.ResultSet) - {rset-100002} Result: [2, Update Web Service, Self-explanatory, 2007-07-06] [2007-07-02 09:30:33,664] DEBUG (org.springframework.jdbc.datasource.DataSourceUtils) - Returning JDBC Connection to DataSource [2007-07-02 09:30:33,664] DEBUG (org.springframework.jdbc.datasource.DataSourceUtils) - Returning JDBC Connection to DataSource


Reply With Quote
