Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:51:03+00:00 2026-05-27T02:51:03+00:00

I have a web application set up with MyBatis and Spring, but it doesn’t

  • 0

I have a web application set up with MyBatis and Spring, but it doesn’t seem to be using any transactions. Here’s the configuration:

applicationContext.xml:

<tx:annotation-driven />

<!-- <tx:jta-transaction-manager /> --> <!-- using WebSphere 7 -->

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/my_datasource" />
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="configLocation" value="WEB-INF/mybatis-config.xml" />
    <property name="dataSource" ref="dataSource" />
</bean>

<bean id="testDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="com.lmig.TestDAO" />
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

Sample bean method with transaction definition:

@Transactional(propagation = Propagation.REQUIRED)
public void testDelete() {
    testDAO.firstDelete(); //always successful
    testDAO.secondDelete(); //always throws SQLServerException
}

TestDAO:

public interface TestDAO {
    public void firstDelete();
    public void secondDelete();
}

Server debug log:

[11/17/11 16:42:07:998 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Creating SqlSession with JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@34ba34ba] 
[11/17/11 16:42:07:999 PST] 0000002b SystemOut     O DEBUG [java.sql.Connection] ooo Connection Opened 
[11/17/11 16:42:08:001 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@34ba34ba] will be managed by Spring 
[11/17/11 16:42:08:005 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74247424] 
[11/17/11 16:42:08:025 PST] 0000002b SystemOut     O DEBUG [java.sql.PreparedStatement] ==>  Executing: delete from test1  
[11/17/11 16:42:08:025 PST] 0000002b SystemOut     O DEBUG [java.sql.PreparedStatement] ==> Parameters:  
[11/17/11 16:42:08:097 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74247424] 
[11/17/11 16:42:08:099 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74247424] 
[11/17/11 16:42:08:123 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74247424] 
[11/17/11 16:42:08:136 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Creating SqlSession with JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@17351735] 
[11/17/11 16:42:08:137 PST] 0000002b SystemOut     O DEBUG [java.sql.Connection] ooo Connection Opened 
[11/17/11 16:42:08:138 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] JDBC Connection [com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@17351735] will be managed by Spring 
[11/17/11 16:42:08:139 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d871d87] 
[11/17/11 16:42:08:145 PST] 0000002b SystemOut     O DEBUG [java.sql.PreparedStatement] ==>  Executing: delete from test2  
[11/17/11 16:42:08:146 PST] 0000002b SystemOut     O DEBUG [java.sql.PreparedStatement] ==> Parameters:
[11/17/11 16:42:08:490 PST] 0000002b XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
[11/17/11 16:42:08:554 PST] 0000002b SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFactory <init> SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
[11/17/11 16:42:08:560 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d871d87] 
[11/17/11 16:42:08:597 PST] 0000002b SystemOut     O DEBUG [org.mybatis.spring.SqlSessionUtils] Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d871d87]
...SQLServerException follows...

Since secondDelete() throws an exception, the entire transaction would be expected to roll back. However, this isn’t the case, and the firstDelete() is still committed. I’ve tried all combinations of the transaction manager config (Spring-managed, app server-managed, both) but I keep getting the same results. Any idea what I’m doing wrong?

I’m using Mybatis 3, Spring 3 on WebSphere 7 with SQL Server 2005 as the DB.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:51:04+00:00Added an answer on May 27, 2026 at 2:51 am

    I figured this out: my testDelete() method wasn’t a Spring-managed bean, so it wasn’t participating in Spring-managed transactions. I changed my configuration to this, and now it’s working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an ASP.net 2.0 web application which is using themes set on the
I have a web application that has set to navigate its input fields using
I have a web application built using jsp/servlets.The web application session is set to
I have a web application that has one set of files used by 50+
In my web application we have many users.I want to set permission for each
I have web application written in java using Eclipse. It has just one servlet
I have a web application set up on our intranet that uses windows authentication
I have a requirement within the same web application to set 2 session timeouts.
I have a web application running in a kiosk, which is set up with
Here's the situation: I have a web application which response to a request for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.