Spring aop transaction not committing the transaction with mybatis

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Spring aop transaction not committing the transaction with mybatis

Sharad Yadav

I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache Tomcat 6.0.29.

I have used declarative transactions of spring for transaction management. The issue is that the transactions are not working for me. The transaction works for sometime and then suddenly stops working. I can go and do multiple inserts and updates and all will work for 1 time or 10 time or 20 time there no fix patterna dn suddenly stops.

I even tried the annotation driven transaction but the issue is same. I tried the session open and close on the template and that works but that does not help as I don't to maintain transaction in my DAO layer but manage via service layer.

I have tried checking all my configs but no clue. Any pointers?

My configurations looks like this -

    <tx:advice id="txAdvice" transaction-manager="transactionManager">
       
<tx:attributes>
           
<tx:method name="*" propagation="REQUIRED" />
       
</tx:attributes>
   
</tx:advice>

   
<aop:config>
       
<aop:pointcut id="dtxops"
           
expression="execution(* com.service.*.*(..))" />
       
<aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
   
</aop:config>

TX Manager and DS config -

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

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
       
<property name="resourceRef" value="true" />
       
<property name="jndiName" value="java:comp/env/jdbc/MyDBInstance" />
   
</bean>
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Eduardo Macarron
That config seems right. Could you post the rest of your appContext
(services + mappers)?

On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:

> I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache
> Tomcat 6.0.29.
>
> I have used declarative transactions of spring for transaction management.
> The issue is that the transactions are not working for me. The transaction
> works for sometime and then suddenly stops working. I can go and do multiple
> inserts and updates and all will work for 1 time or 10 time or 20 time there
> no fix patterna dn suddenly stops.
>
> I even tried the annotation driven transaction but the issue is same. I
> tried the session open and close on the template and that works but that
> does not help as I don't to maintain transaction in my DAO layer but manage
> via service layer.
>
> I have tried checking all my configs but no clue. Any pointers?
>
> My configurations looks like this -
>
>     <tx:advice id="txAdvice" transaction-manager="transactionManager">
>         <tx:attributes>
>             <tx:method name="*" propagation="REQUIRED" />
>         </tx:attributes>
>     </tx:advice>
>
>     <aop:config>
>         <aop:pointcut id="dtxops"
>             expression="execution(* com.service.*.*(..))" />
>         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
>     </aop:config>
>
> TX Manager and DS config -
>
> <bean id="transactionManager"
>         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>         <property name="dataSource">
>             <ref bean="dataSource" />
>         </property>
>     </bean>
>
> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
>         <property name="resourceRef" value="true" />
>         <property name="jndiName" value="java:comp/env/jdbc/MyDBInstance" />
>     </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Sharad Yadav
Here are the details, let me know if any more info is required.

Person.xml mapper file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.api.Person">
<resultMap type="Person" id="personResultMap">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="description" column="description" />
</resultMap>

<insert id="create" parameterType="Person">
insert into
person
(id,name,description)
values
(#{id},#{name},#{description})
</insert>
</mapper>

SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias type="com.api.Person"
alias="Person" />
</typeAliases>

<mappers>
<mapper resource="dao/ibatis/Person.xml" />
</mappers>
</configuration>

Related spring config and also default-autowire="byName" is set.

<context:component-scan base-package="com.accept.ppm.dao">
<context:include-filter type="annotation"
            expression="org.springframework.stereotype.Repository"/>
    </context:component-scan>
<context:component-scan base-package="com.accept.ppm.service">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Component" />
</context:component-scan>

<bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation">
<value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>

DAO class -

public interface PersonDAO {
void create(Person person);
}

@Repository("personDAO")
public class SqlMapPersonDAO extends SqlSessionDaoSupport implements PersonDAO {
        @Override
public void create(Person person) {
SqlSessionTemplate template = getSqlSessionTemplate();
template.insert("com.api.Person.create", person);
}
}

Service class -

public interface PersonService {
void create(Person person);
}

@Component("personService")
public class PersonServiceImpl extends PersonService {
        private PersonDAO personDAO;

public void setPersonDAO(PersonDAO personDAO) {
this.personDAO= personDAO;
}

        @Override
public void create(Person person) {
SqlSessionTemplate template = getSqlSessionTemplate();
template.insert("com.api.Person.create", person);
}
}

On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <[hidden email]> wrote:
That config seems right. Could you post the rest of your appContext
(services + mappers)?

On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache
> Tomcat 6.0.29.
>
> I have used declarative transactions of spring for transaction management.
> The issue is that the transactions are not working for me. The transaction
> works for sometime and then suddenly stops working. I can go and do multiple
> inserts and updates and all will work for 1 time or 10 time or 20 time there
> no fix patterna dn suddenly stops.
>
> I even tried the annotation driven transaction but the issue is same. I
> tried the session open and close on the template and that works but that
> does not help as I don't to maintain transaction in my DAO layer but manage
> via service layer.
>
> I have tried checking all my configs but no clue. Any pointers?
>
> My configurations looks like this -
>
>     <tx:advice id="txAdvice" transaction-manager="transactionManager">
>         <tx:attributes>
>             <tx:method name="*" propagation="REQUIRED" />
>         </tx:attributes>
>     </tx:advice>
>
>     <aop:config>
>         <aop:pointcut id="dtxops"
>             expression="execution(* com.service.*.*(..))" />
>         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
>     </aop:config>
>
> TX Manager and DS config -
>
> <bean id="transactionManager"
>         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
>         <property name="dataSource">
>             <ref bean="dataSource" />
>         </property>
>     </bean>
>
> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
>         <property name="resourceRef" value="true" />
>         <property name="jndiName" value="java:comp/env/jdbc/MyDBInstance" />
>     </bean>

Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Eduardo Macarron
I cannot see anything wrong.

Maybe you could execute your app with a logger "org.mybatis.spring"
set to debug to see what is happening?

On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:

> Here are the details, let me know if any more info is required.
>
> Person.xml mapper file
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> <mapper namespace="com.api.Person">
> <resultMap type="Person" id="personResultMap">
> <id property="id" column="id" />
> <result property="name" column="name" />
> <result property="description" column="description" />
> </resultMap>
>
> <insert id="create" parameterType="Person">
> insert into
> person
> (id,name,description)
> values
> (#{id},#{name},#{description})
> </insert>
> </mapper>
>
> SqlMapConfig.xml
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
> <configuration>
> <typeAliases>
> <typeAlias type="com.api.Person"
> alias="Person" />
> </typeAliases>
>
> <mappers>
> <mapper resource="dao/ibatis/Person.xml" />
> </mappers>
> </configuration>
>
> Related spring config and also default-autowire="byName" is set.
>
> <context:component-scan base-package="com.accept.ppm.dao">
> <context:include-filter type="annotation"
>             expression="org.springframework.stereotype.Repository"/>
>     </context:component-scan>
> <context:component-scan base-package="com.accept.ppm.service">
> <context:include-filter type="annotation"
> expression="org.springframework.stereotype.Component" />
> </context:component-scan>
>
> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
> <property name="configLocation">
> <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> </property>
> <property name="dataSource">
> <ref bean="dataSource" />
> </property>
> </bean>
>
> DAO class -
>
> public interface PersonDAO {
> void create(Person person);
>
> }
>
> @Repository("personDAO")
> public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> PersonDAO {
>         @Override
> public void create(Person person) {
> SqlSessionTemplate template = getSqlSessionTemplate();
> template.insert("com.api.Person.create", person);
>
> }
> }
>
> Service class -
>
> public interface PersonService {
> void create(Person person);
>
> }
>
> @Component("personService")
> public class PersonServiceImpl extends PersonService {
>         private PersonDAO personDAO;
>
> public void setPersonDAO(PersonDAO personDAO) {
> this.personDAO= personDAO;
>
> }
>
>         @Override
> public void create(Person person) {
> SqlSessionTemplate template = getSqlSessionTemplate();
> template.insert("com.api.Person.create", person);
>
> }
> }
>
> On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <[hidden email]>wrote:
>
>
>
>
>
>
>
> > That config seems right. Could you post the rest of your appContext
> > (services + mappers)?
>
> > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache
> > > Tomcat 6.0.29.
>
> > > I have used declarative transactions of spring for transaction
> > management.
> > > The issue is that the transactions are not working for me. The
> > transaction
> > > works for sometime and then suddenly stops working. I can go and do
> > multiple
> > > inserts and updates and all will work for 1 time or 10 time or 20 time
> > there
> > > no fix patterna dn suddenly stops.
>
> > > I even tried the annotation driven transaction but the issue is same. I
> > > tried the session open and close on the template and that works but that
> > > does not help as I don't to maintain transaction in my DAO layer but
> > manage
> > > via service layer.
>
> > > I have tried checking all my configs but no clue. Any pointers?
>
> > > My configurations looks like this -
>
> > >     <tx:advice id="txAdvice" transaction-manager="transactionManager">
> > >         <tx:attributes>
> > >             <tx:method name="*" propagation="REQUIRED" />
> > >         </tx:attributes>
> > >     </tx:advice>
>
> > >     <aop:config>
> > >         <aop:pointcut id="dtxops"
> > >             expression="execution(* com.service.*.*(..))" />
> > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
> > >     </aop:config>
>
> > > TX Manager and DS config -
>
> > > <bean id="transactionManager"
>
> > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > >         <property name="dataSource">
> > >             <ref bean="dataSource" />
> > >         </property>
> > >     </bean>
>
> > > <bean id="dataSource"
> > class="org.springframework.jndi.JndiObjectFactoryBean">
> > >         <property name="resourceRef" value="true" />
> > >         <property name="jndiName" value="java:comp/env/jdbc/MyDBInstance"
> > />
> > >     </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Sharad Yadav
I have already done that but nothing in the logs.

One more observation - once commit stops working it never recovers for that http session until a new http session is created. Also if one user session gets the problem all the http session starts getting the same issue. Now if i create a new http session then all the previous http session starts working.


On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <[hidden email]> wrote:
I cannot see anything wrong.

Maybe you could execute your app with a logger "org.mybatis.spring"
set to debug to see what is happening?

On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> Here are the details, let me know if any more info is required.
>
> Person.xml mapper file
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> <mapper namespace="com.api.Person">
> <resultMap type="Person" id="personResultMap">
> <id property="id" column="id" />
> <result property="name" column="name" />
> <result property="description" column="description" />
> </resultMap>
>
> <insert id="create" parameterType="Person">
> insert into
> person
> (id,name,description)
> values
> (#{id},#{name},#{description})
> </insert>
> </mapper>
>
> SqlMapConfig.xml
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
> <configuration>
> <typeAliases>
> <typeAlias type="com.api.Person"
> alias="Person" />
> </typeAliases>
>
> <mappers>
> <mapper resource="dao/ibatis/Person.xml" />
> </mappers>
> </configuration>
>
> Related spring config and also default-autowire="byName" is set.
>
> <context:component-scan base-package="com.accept.ppm.dao">
> <context:include-filter type="annotation"
>             expression="org.springframework.stereotype.Repository"/>
>     </context:component-scan>
> <context:component-scan base-package="com.accept.ppm.service">
> <context:include-filter type="annotation"
> expression="org.springframework.stereotype.Component" />
> </context:component-scan>
>
> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
> <property name="configLocation">
> <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> </property>
> <property name="dataSource">
> <ref bean="dataSource" />
> </property>
> </bean>
>
> DAO class -
>
> public interface PersonDAO {
> void create(Person person);
>
> }
>
> @Repository("personDAO")
> public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> PersonDAO {
>         @Override
> public void create(Person person) {
> SqlSessionTemplate template = getSqlSessionTemplate();
> template.insert("com.api.Person.create", person);
>
> }
> }
>
> Service class -
>
> public interface PersonService {
> void create(Person person);
>
> }
>
> @Component("personService")
> public class PersonServiceImpl extends PersonService {
>         private PersonDAO personDAO;
>
> public void setPersonDAO(PersonDAO personDAO) {
> this.personDAO= personDAO;
>
> }
>
>         @Override
> public void create(Person person) {
> SqlSessionTemplate template = getSqlSessionTemplate();
> template.insert("com.api.Person.create", person);
>
> }
> }
>
> On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <[hidden email]>wrote:
>
>
>
>
>
>
>
> > That config seems right. Could you post the rest of your appContext
> > (services + mappers)?
>
> > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache
> > > Tomcat 6.0.29.
>
> > > I have used declarative transactions of spring for transaction
> > management.
> > > The issue is that the transactions are not working for me. The
> > transaction
> > > works for sometime and then suddenly stops working. I can go and do
> > multiple
> > > inserts and updates and all will work for 1 time or 10 time or 20 time
> > there
> > > no fix patterna dn suddenly stops.
>
> > > I even tried the annotation driven transaction but the issue is same. I
> > > tried the session open and close on the template and that works but that
> > > does not help as I don't to maintain transaction in my DAO layer but
> > manage
> > > via service layer.
>
> > > I have tried checking all my configs but no clue. Any pointers?
>
> > > My configurations looks like this -
>
> > >     <tx:advice id="txAdvice" transaction-manager="transactionManager">
> > >         <tx:attributes>
> > >             <tx:method name="*" propagation="REQUIRED" />
> > >         </tx:attributes>
> > >     </tx:advice>
>
> > >     <aop:config>
> > >         <aop:pointcut id="dtxops"
> > >             expression="execution(* com.service.*.*(..))" />
> > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
> > >     </aop:config>
>
> > > TX Manager and DS config -
>
> > > <bean id="transactionManager"
>
> > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > >         <property name="dataSource">
> > >             <ref bean="dataSource" />
> > >         </property>
> > >     </bean>
>
> > > <bean id="dataSource"
> > class="org.springframework.jndi.JndiObjectFactoryBean">
> > >         <property name="resourceRef" value="true" />
> > >         <property name="jndiName" value="java:comp/env/jdbc/MyDBInstance"
> > />
> > >     </bean>

Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Eduardo Macarron
But something should be printed. I.e. this is the output of the test:

Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
package
Registering MyBatis mappers
Registering MyBatis mapper with 'interface
org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
Property 'configLocation' not specified, using default MyBatis
Configuration
Property 'mapperLocations' was not specified, only MyBatis mapper
files specified in the config xml were loaded
Property 'configLocation' not specified, using default MyBatis
Configuration
Property 'mapperLocations' was not specified, only MyBatis mapper
files specified in the config xml were loaded
Creating SqlSession from SqlSessionFactory
Registering transaction synchronization for SqlSession
Transaction synchronization committed SqlSession
Transaction synchronization closed SqlSession

Regarding the session..what data are you storing in your session?


On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:

> I have already done that but nothing in the logs.
>
> One more observation - once commit stops working it never recovers for that
> http session until a new http session is created. Also if one user session
> gets the problem all the http session starts getting the same issue. Now if
> i create a new http session then all the previous http session starts
> working.
>
> On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <[hidden email]>wrote:
>
>
>
>
>
>
>
> > I cannot see anything wrong.
>
> > Maybe you could execute your app with a logger "org.mybatis.spring"
> > set to debug to see what is happening?
>
> > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > Here are the details, let me know if any more info is required.
>
> > > Person.xml mapper file
>
> > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > <mapper namespace="com.api.Person">
> > > <resultMap type="Person" id="personResultMap">
> > > <id property="id" column="id" />
> > > <result property="name" column="name" />
> > > <result property="description" column="description" />
> > > </resultMap>
>
> > > <insert id="create" parameterType="Person">
> > > insert into
> > > person
> > > (id,name,description)
> > > values
> > > (#{id},#{name},#{description})
> > > </insert>
> > > </mapper>
>
> > > SqlMapConfig.xml
>
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "
> >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > <configuration>
> > > <typeAliases>
> > > <typeAlias type="com.api.Person"
> > > alias="Person" />
> > > </typeAliases>
>
> > > <mappers>
> > > <mapper resource="dao/ibatis/Person.xml" />
> > > </mappers>
> > > </configuration>
>
> > > Related spring config and also default-autowire="byName" is set.
>
> > > <context:component-scan base-package="com.accept.ppm.dao">
> > > <context:include-filter type="annotation"
> > >             expression="org.springframework.stereotype.Repository"/>
> > >     </context:component-scan>
> > > <context:component-scan base-package="com.accept.ppm.service">
> > > <context:include-filter type="annotation"
> > > expression="org.springframework.stereotype.Component" />
> > > </context:component-scan>
>
> > > <bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
> > > <property name="configLocation">
> > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > </property>
> > > <property name="dataSource">
> > > <ref bean="dataSource" />
> > > </property>
> > > </bean>
>
> > > DAO class -
>
> > > public interface PersonDAO {
> > > void create(Person person);
>
> > > }
>
> > > @Repository("personDAO")
> > > public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> > > PersonDAO {
> > >         @Override
> > > public void create(Person person) {
> > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > template.insert("com.api.Person.create", person);
>
> > > }
> > > }
>
> > > Service class -
>
> > > public interface PersonService {
> > > void create(Person person);
>
> > > }
>
> > > @Component("personService")
> > > public class PersonServiceImpl extends PersonService {
> > >         private PersonDAO personDAO;
>
> > > public void setPersonDAO(PersonDAO personDAO) {
> > > this.personDAO= personDAO;
>
> > > }
>
> > >         @Override
> > > public void create(Person person) {
> > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > template.insert("com.api.Person.create", person);
>
> > > }
> > > }
>
> > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <[hidden email]
> > >wrote:
>
> > > > That config seems right. Could you post the rest of your appContext
> > > > (services + mappers)?
>
> > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on
> > Apache
> > > > > Tomcat 6.0.29.
>
> > > > > I have used declarative transactions of spring for transaction
> > > > management.
> > > > > The issue is that the transactions are not working for me. The
> > > > transaction
> > > > > works for sometime and then suddenly stops working. I can go and do
> > > > multiple
> > > > > inserts and updates and all will work for 1 time or 10 time or 20
> > time
> > > > there
> > > > > no fix patterna dn suddenly stops.
>
> > > > > I even tried the annotation driven transaction but the issue is same.
> > I
> > > > > tried the session open and close on the template and that works but
> > that
> > > > > does not help as I don't to maintain transaction in my DAO layer but
> > > > manage
> > > > > via service layer.
>
> > > > > I have tried checking all my configs but no clue. Any pointers?
>
> > > > > My configurations looks like this -
>
> > > > >     <tx:advice id="txAdvice"
> > transaction-manager="transactionManager">
> > > > >         <tx:attributes>
> > > > >             <tx:method name="*" propagation="REQUIRED" />
> > > > >         </tx:attributes>
> > > > >     </tx:advice>
>
> > > > >     <aop:config>
> > > > >         <aop:pointcut id="dtxops"
> > > > >             expression="execution(* com.service.*.*(..))" />
> > > > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
> > > > >     </aop:config>
>
> > > > > TX Manager and DS config -
>
> > > > > <bean id="transactionManager"
>
> > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > > > >         <property name="dataSource">
> > > > >             <ref bean="dataSource" />
> > > > >         </property>
> > > > >     </bean>
>
> > > > > <bean id="dataSource"
> > > > class="org.springframework.jndi.JndiObjectFactoryBean">
> > > > >         <property name="resourceRef" value="true" />
> > > > >         <property name="jndiName"
> > value="java:comp/env/jdbc/MyDBInstance"
> > > > />
> > > > >     </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Sharad Yadav
I am not storing anything in the session.

I am getting only this in the log at DEBUG level -

DEBUG 2010-10-28 17:40:57,312 [http-9090-1] org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
DEBUG 2010-10-28 17:40:57,752 [http-9090-1] org.mybatis.spring.SqlSessionUtils - Creating SqlSession from SqlSessionFactory

On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]> wrote:
But something should be printed. I.e. this is the output of the test:

Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
package
Registering MyBatis mappers
Registering MyBatis mapper with 'interface
org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
Property 'configLocation' not specified, using default MyBatis
Configuration
Property 'mapperLocations' was not specified, only MyBatis mapper
files specified in the config xml were loaded
Property 'configLocation' not specified, using default MyBatis
Configuration
Property 'mapperLocations' was not specified, only MyBatis mapper
files specified in the config xml were loaded
Creating SqlSession from SqlSessionFactory
Registering transaction synchronization for SqlSession
Transaction synchronization committed SqlSession
Transaction synchronization closed SqlSession

Regarding the session..what data are you storing in your session?


On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> I have already done that but nothing in the logs.
>
> One more observation - once commit stops working it never recovers for that
> http session until a new http session is created. Also if one user session
> gets the problem all the http session starts getting the same issue. Now if
> i create a new http session then all the previous http session starts
> working.
>
> On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <[hidden email]>wrote:
>
>
>
>
>
>
>
> > I cannot see anything wrong.
>
> > Maybe you could execute your app with a logger "org.mybatis.spring"
> > set to debug to see what is happening?
>
> > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > Here are the details, let me know if any more info is required.
>
> > > Person.xml mapper file
>
> > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > <mapper namespace="com.api.Person">
> > > <resultMap type="Person" id="personResultMap">
> > > <id property="id" column="id" />
> > > <result property="name" column="name" />
> > > <result property="description" column="description" />
> > > </resultMap>
>
> > > <insert id="create" parameterType="Person">
> > > insert into
> > > person
> > > (id,name,description)
> > > values
> > > (#{id},#{name},#{description})
> > > </insert>
> > > </mapper>
>
> > > SqlMapConfig.xml
>
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "
> >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > <configuration>
> > > <typeAliases>
> > > <typeAlias type="com.api.Person"
> > > alias="Person" />
> > > </typeAliases>
>
> > > <mappers>
> > > <mapper resource="dao/ibatis/Person.xml" />
> > > </mappers>
> > > </configuration>
>
> > > Related spring config and also default-autowire="byName" is set.
>
> > > <context:component-scan base-package="com.accept.ppm.dao">
> > > <context:include-filter type="annotation"
> > >             expression="org.springframework.stereotype.Repository"/>
> > >     </context:component-scan>
> > > <context:component-scan base-package="com.accept.ppm.service">
> > > <context:include-filter type="annotation"
> > > expression="org.springframework.stereotype.Component" />
> > > </context:component-scan>
>
> > > <bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
> > > <property name="configLocation">
> > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > </property>
> > > <property name="dataSource">
> > > <ref bean="dataSource" />
> > > </property>
> > > </bean>
>
> > > DAO class -
>
> > > public interface PersonDAO {
> > > void create(Person person);
>
> > > }
>
> > > @Repository("personDAO")
> > > public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> > > PersonDAO {
> > >         @Override
> > > public void create(Person person) {
> > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > template.insert("com.api.Person.create", person);
>
> > > }
> > > }
>
> > > Service class -
>
> > > public interface PersonService {
> > > void create(Person person);
>
> > > }
>
> > > @Component("personService")
> > > public class PersonServiceImpl extends PersonService {
> > >         private PersonDAO personDAO;
>
> > > public void setPersonDAO(PersonDAO personDAO) {
> > > this.personDAO= personDAO;
>
> > > }
>
> > >         @Override
> > > public void create(Person person) {
> > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > template.insert("com.api.Person.create", person);
>
> > > }
> > > }
>
> > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <[hidden email]
> > >wrote:
>
> > > > That config seems right. Could you post the rest of your appContext
> > > > (services + mappers)?
>
> > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on
> > Apache
> > > > > Tomcat 6.0.29.
>
> > > > > I have used declarative transactions of spring for transaction
> > > > management.
> > > > > The issue is that the transactions are not working for me. The
> > > > transaction
> > > > > works for sometime and then suddenly stops working. I can go and do
> > > > multiple
> > > > > inserts and updates and all will work for 1 time or 10 time or 20
> > time
> > > > there
> > > > > no fix patterna dn suddenly stops.
>
> > > > > I even tried the annotation driven transaction but the issue is same.
> > I
> > > > > tried the session open and close on the template and that works but
> > that
> > > > > does not help as I don't to maintain transaction in my DAO layer but
> > > > manage
> > > > > via service layer.
>
> > > > > I have tried checking all my configs but no clue. Any pointers?
>
> > > > > My configurations looks like this -
>
> > > > >     <tx:advice id="txAdvice"
> > transaction-manager="transactionManager">
> > > > >         <tx:attributes>
> > > > >             <tx:method name="*" propagation="REQUIRED" />
> > > > >         </tx:attributes>
> > > > >     </tx:advice>
>
> > > > >     <aop:config>
> > > > >         <aop:pointcut id="dtxops"
> > > > >             expression="execution(* com.service.*.*(..))" />
> > > > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
> > > > >     </aop:config>
>
> > > > > TX Manager and DS config -
>
> > > > > <bean id="transactionManager"
>
> > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > > > >         <property name="dataSource">
> > > > >             <ref bean="dataSource" />
> > > > >         </property>
> > > > >     </bean>
>
> > > > > <bean id="dataSource"
> > > > class="org.springframework.jndi.JndiObjectFactoryBean">
> > > > >         <property name="resourceRef" value="true" />
> > > > >         <property name="jndiName"
> > value="java:comp/env/jdbc/MyDBInstance"
> > > > />
> > > > >     </bean>

Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Eduardo Macarron
Could you mail us some code to see if we can reproduce it?

On 28 oct, 14:12, Kamran Yadav <[hidden email]> wrote:

> I am not storing anything in the session.
>
> I am getting only this in the log at DEBUG level -
>
> DEBUG 2010-10-28 17:40:57,312 [http-9090-1]
> org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
> Connection from DataSource
> DEBUG 2010-10-28 17:40:57,752 [http-9090-1]
> org.mybatis.spring.SqlSessionUtils - Creating SqlSession from
> SqlSessionFactory
>
>
>
>
>
>
>
> On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]> wrote:
> > But something should be printed. I.e. this is the output of the test:
>
> > Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
> > package
> > Registering MyBatis mappers
> > Registering MyBatis mapper with 'interface
> > org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
> > Property 'configLocation' not specified, using default MyBatis
> > Configuration
> > Property 'mapperLocations' was not specified, only MyBatis mapper
> > files specified in the config xml were loaded
> > Property 'configLocation' not specified, using default MyBatis
> > Configuration
> > Property 'mapperLocations' was not specified, only MyBatis mapper
> > files specified in the config xml were loaded
> > Creating SqlSession from SqlSessionFactory
> > Registering transaction synchronization for SqlSession
> > Transaction synchronization committed SqlSession
> > Transaction synchronization closed SqlSession
>
> > Regarding the session..what data are you storing in your session?
>
> > On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> > > I have already done that but nothing in the logs.
>
> > > One more observation - once commit stops working it never recovers for
> > that
> > > http session until a new http session is created. Also if one user
> > session
> > > gets the problem all the http session starts getting the same issue. Now
> > if
> > > i create a new http session then all the previous http session starts
> > > working.
>
> > > On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <[hidden email]
> > >wrote:
>
> > > > I cannot see anything wrong.
>
> > > > Maybe you could execute your app with a logger "org.mybatis.spring"
> > > > set to debug to see what is happening?
>
> > > > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > > > Here are the details, let me know if any more info is required.
>
> > > > > Person.xml mapper file
>
> > > > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> > > >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > > > <mapper namespace="com.api.Person">
> > > > > <resultMap type="Person" id="personResultMap">
> > > > > <id property="id" column="id" />
> > > > > <result property="name" column="name" />
> > > > > <result property="description" column="description" />
> > > > > </resultMap>
>
> > > > > <insert id="create" parameterType="Person">
> > > > > insert into
> > > > > person
> > > > > (id,name,description)
> > > > > values
> > > > > (#{id},#{name},#{description})
> > > > > </insert>
> > > > > </mapper>
>
> > > > > SqlMapConfig.xml
>
> > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
> > "
> > > >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > > > <configuration>
> > > > > <typeAliases>
> > > > > <typeAlias type="com.api.Person"
> > > > > alias="Person" />
> > > > > </typeAliases>
>
> > > > > <mappers>
> > > > > <mapper resource="dao/ibatis/Person.xml" />
> > > > > </mappers>
> > > > > </configuration>
>
> > > > > Related spring config and also default-autowire="byName" is set.
>
> > > > > <context:component-scan base-package="com.accept.ppm.dao">
> > > > > <context:include-filter type="annotation"
> > > > >             expression="org.springframework.stereotype.Repository"/>
> > > > >     </context:component-scan>
> > > > > <context:component-scan base-package="com.accept.ppm.service">
> > > > > <context:include-filter type="annotation"
> > > > > expression="org.springframework.stereotype.Component" />
> > > > > </context:component-scan>
>
> > > > > <bean id="sqlSession"
> > class="org.mybatis.spring.SqlSessionFactoryBean">
> > > > > <property name="configLocation">
> > > > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > > > </property>
> > > > > <property name="dataSource">
> > > > > <ref bean="dataSource" />
> > > > > </property>
> > > > > </bean>
>
> > > > > DAO class -
>
> > > > > public interface PersonDAO {
> > > > > void create(Person person);
>
> > > > > }
>
> > > > > @Repository("personDAO")
> > > > > public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> > > > > PersonDAO {
> > > > >         @Override
> > > > > public void create(Person person) {
> > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > template.insert("com.api.Person.create", person);
>
> > > > > }
> > > > > }
>
> > > > > Service class -
>
> > > > > public interface PersonService {
> > > > > void create(Person person);
>
> > > > > }
>
> > > > > @Component("personService")
> > > > > public class PersonServiceImpl extends PersonService {
> > > > >         private PersonDAO personDAO;
>
> > > > > public void setPersonDAO(PersonDAO personDAO) {
> > > > > this.personDAO= personDAO;
>
> > > > > }
>
> > > > >         @Override
> > > > > public void create(Person person) {
> > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > template.insert("com.api.Person.create", person);
>
> > > > > }
> > > > > }
>
> > > > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <
> > [hidden email]
> > > > >wrote:
>
> > > > > > That config seems right. Could you post the rest of your appContext
> > > > > > (services + mappers)?
>
> > > > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0
> > on
> > > > Apache
> > > > > > > Tomcat 6.0.29.
>
> > > > > > > I have used declarative transactions of spring for transaction
> > > > > > management.
> > > > > > > The issue is that the transactions are not working for me. The
> > > > > > transaction
> > > > > > > works for sometime and then suddenly stops working. I can go and
> > do
> > > > > > multiple
> > > > > > > inserts and updates and all will work for 1 time or 10 time or 20
> > > > time
> > > > > > there
> > > > > > > no fix patterna dn suddenly stops.
>
> > > > > > > I even tried the annotation driven transaction but the issue is
> > same.
> > > > I
> > > > > > > tried the session open and close on the template and that works
> > but
> > > > that
> > > > > > > does not help as I don't to maintain transaction in my DAO layer
> > but
> > > > > > manage
> > > > > > > via service layer.
>
> > > > > > > I have tried checking all my configs but no clue. Any pointers?
>
> > > > > > > My configurations looks like this -
>
> > > > > > >     <tx:advice id="txAdvice"
> > > > transaction-manager="transactionManager">
> > > > > > >         <tx:attributes>
> > > > > > >             <tx:method name="*" propagation="REQUIRED" />
> > > > > > >         </tx:attributes>
> > > > > > >     </tx:advice>
>
> > > > > > >     <aop:config>
> > > > > > >         <aop:pointcut id="dtxops"
> > > > > > >             expression="execution(* com.service.*.*(..))" />
> > > > > > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops"
> > />
> > > > > > >     </aop:config>
>
> > > > > > > TX Manager and DS config -
>
> > > > > > > <bean id="transactionManager"
>
> > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > > > > > >         <property name="dataSource">
> > > > > > >             <ref bean="dataSource" />
> > > > > > >         </property>
> > > > > > >     </bean>
>
> > > > > > > <bean id="dataSource"
> > > > > > class="org.springframework.jndi.JndiObjectFactoryBean">
> > > > > > >         <property name="resourceRef" value="true" />
> > > > > > >         <property name="jndiName"
> > > > value="java:comp/env/jdbc/MyDBInstance"
> > > > > > />
> > > > > > >     </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Hunter
If you never see something like the following in the debug output,
something is wrong:
DEBUG springframework.jdbc.datasource.DataSourceUtils Returning JDBC
Connection to DataSource

What is the code that is calling PersonService.create()? I assume it's
just a web request?

On Oct 28, 9:20 am, Eduardo <[hidden email]> wrote:

> Could you mail us some code to see if we can reproduce it?
>
> On 28 oct, 14:12, Kamran Yadav <[hidden email]> wrote:
>
>
>
> > I am not storing anything in the session.
>
> > I am getting only this in the log at DEBUG level -
>
> > DEBUG 2010-10-28 17:40:57,312 [http-9090-1]
> > org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
> > Connection from DataSource
> > DEBUG 2010-10-28 17:40:57,752 [http-9090-1]
> > org.mybatis.spring.SqlSessionUtils - Creating SqlSession from
> > SqlSessionFactory
>
> > On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]> wrote:
> > > But something should be printed. I.e. this is the output of the test:
>
> > > Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
> > > package
> > > Registering MyBatis mappers
> > > Registering MyBatis mapper with 'interface
> > > org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
> > > Property 'configLocation' not specified, using default MyBatis
> > > Configuration
> > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > files specified in the config xml were loaded
> > > Property 'configLocation' not specified, using default MyBatis
> > > Configuration
> > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > files specified in the config xml were loaded
> > > Creating SqlSession from SqlSessionFactory
> > > Registering transaction synchronization for SqlSession
> > > Transaction synchronization committed SqlSession
> > > Transaction synchronization closed SqlSession
>
> > > Regarding the session..what data are you storing in your session?
>
> > > On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> > > > I have already done that but nothing in the logs.
>
> > > > One more observation - once commit stops working it never recovers for
> > > that
> > > > http session until a new http session is created. Also if one user
> > > session
> > > > gets the problem all the http session starts getting the same issue. Now
> > > if
> > > > i create a new http session then all the previous http session starts
> > > > working.
>
> > > > On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <[hidden email]
> > > >wrote:
>
> > > > > I cannot see anything wrong.
>
> > > > > Maybe you could execute your app with a logger "org.mybatis.spring"
> > > > > set to debug to see what is happening?
>
> > > > > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > > > > Here are the details, let me know if any more info is required.
>
> > > > > > Person.xml mapper file
>
> > > > > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > > > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> > > > >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > > > > <mapper namespace="com.api.Person">
> > > > > > <resultMap type="Person" id="personResultMap">
> > > > > > <id property="id" column="id" />
> > > > > > <result property="name" column="name" />
> > > > > > <result property="description" column="description" />
> > > > > > </resultMap>
>
> > > > > > <insert id="create" parameterType="Person">
> > > > > > insert into
> > > > > > person
> > > > > > (id,name,description)
> > > > > > values
> > > > > > (#{id},#{name},#{description})
> > > > > > </insert>
> > > > > > </mapper>
>
> > > > > > SqlMapConfig.xml
>
> > > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
> > > "
> > > > >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > > > > <configuration>
> > > > > > <typeAliases>
> > > > > > <typeAlias type="com.api.Person"
> > > > > > alias="Person" />
> > > > > > </typeAliases>
>
> > > > > > <mappers>
> > > > > > <mapper resource="dao/ibatis/Person.xml" />
> > > > > > </mappers>
> > > > > > </configuration>
>
> > > > > > Related spring config and also default-autowire="byName" is set.
>
> > > > > > <context:component-scan base-package="com.accept.ppm.dao">
> > > > > > <context:include-filter type="annotation"
> > > > > >             expression="org.springframework.stereotype.Repository"/>
> > > > > >     </context:component-scan>
> > > > > > <context:component-scan base-package="com.accept.ppm.service">
> > > > > > <context:include-filter type="annotation"
> > > > > > expression="org.springframework.stereotype.Component" />
> > > > > > </context:component-scan>
>
> > > > > > <bean id="sqlSession"
> > > class="org.mybatis.spring.SqlSessionFactoryBean">
> > > > > > <property name="configLocation">
> > > > > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > > > > </property>
> > > > > > <property name="dataSource">
> > > > > > <ref bean="dataSource" />
> > > > > > </property>
> > > > > > </bean>
>
> > > > > > DAO class -
>
> > > > > > public interface PersonDAO {
> > > > > > void create(Person person);
>
> > > > > > }
>
> > > > > > @Repository("personDAO")
> > > > > > public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> > > > > > PersonDAO {
> > > > > >         @Override
> > > > > > public void create(Person person) {
> > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > }
> > > > > > }
>
> > > > > > Service class -
>
> > > > > > public interface PersonService {
> > > > > > void create(Person person);
>
> > > > > > }
>
> > > > > > @Component("personService")
> > > > > > public class PersonServiceImpl extends PersonService {
> > > > > >         private PersonDAO personDAO;
>
> > > > > > public void setPersonDAO(PersonDAO personDAO) {
> > > > > > this.personDAO= personDAO;
>
> > > > > > }
>
> > > > > >         @Override
> > > > > > public void create(Person person) {
> > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > }
> > > > > > }
>
> > > > > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <
> > > [hidden email]
> > > > > >wrote:
>
> > > > > > > That config seems right. Could you post the rest of your appContext
> > > > > > > (services + mappers)?
>
> > > > > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > > > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0
> > > on
> > > > > Apache
> > > > > > > > Tomcat 6.0.29.
>
> > > > > > > > I have used declarative transactions of spring for transaction
> > > > > > > management.
> > > > > > > > The issue is that the transactions are not working for me. The
> > > > > > > transaction
> > > > > > > > works for sometime and then suddenly stops working. I can go and
> > > do
> > > > > > > multiple
> > > > > > > > inserts and updates and all will work for 1 time or 10 time or 20
> > > > > time
> > > > > > > there
> > > > > > > > no fix patterna dn suddenly stops.
>
> > > > > > > > I even tried the annotation driven transaction but the issue is
> > > same.
> > > > > I
> > > > > > > > tried the session open and close on the template and that works
> > > but
> > > > > that
> > > > > > > > does not help as I don't to maintain transaction in my DAO layer
> > > but
> > > > > > > manage
> > > > > > > > via service layer.
>
> > > > > > > > I have tried checking all my configs but no clue. Any pointers?
>
> > > > > > > > My configurations looks like this -
>
> > > > > > > >     <tx:advice id="txAdvice"
> > > > > transaction-manager="transactionManager">
> > > > > > > >         <tx:attributes>
> > > > > > > >             <tx:method name="*" propagation="REQUIRED" />
> > > > > > > >         </tx:attributes>
> > > > > > > >     </tx:advice>
>
> > > > > > > >     <aop:config>
> > > > > > > >         <aop:pointcut id="dtxops"
> > > > > > > >             expression="execution(* com.service.*.*(..))" />
> > > > > > > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops"
> > > />
> > > > > > > >     </aop:config>
>
> > > > > > > > TX Manager and DS config -
>
> > > > > > > > <bean id="transactionManager"
>
> > > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > > > > > > >         <property name="dataSource">
> > > > > > > >             <ref bean="dataSource" />
> > > > > > > >         </property>
> > > > > > > >     </bean>
>
> > > > > > > > <bean id="dataSource"
> > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean">
> > > > > > > >         <property name="resourceRef" value="true" />
> > > > > > > >         <property name="jndiName"
> > > > > value="java:comp/env/jdbc/MyDBInstance"
> > > > > > > />
> > > > > > > >     </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Sharad Yadav
I see this in the logs and there is no "Returning JDBC Connection to DataSource" kind of message.

[10-29 16:50:00] DEBUG org.springframework.jdbc.datasource.DataSourceUtils [http-8080-1]: Fetching JDBC Connection from DataSource
[10-29 16:50:00] DEBUG org.mybatis.spring.SqlSessionUtils [http-8080-1]: Creating SqlSession from SqlSessionFactory
[10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: ooo Connection Opened
[10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>  Executing: INSERT INTO person(id, name, description) VALUES(?, ?, ?) 
[10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==> Parameters: 7(Integer), asdasds(String), asdasdas(String)
[10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: xxx Connection Closed


I have


On Thu, Oct 28, 2010 at 7:55 PM, Hunter <[hidden email]> wrote:
If you never see something like the following in the debug output,
something is wrong:
DEBUG springframework.jdbc.datasource.DataSourceUtils Returning JDBC
Connection to DataSource

What is the code that is calling PersonService.create()? I assume it's
just a web request?

On Oct 28, 9:20 am, Eduardo <[hidden email]> wrote:
> Could you mail us some code to see if we can reproduce it?
>
> On 28 oct, 14:12, Kamran Yadav <[hidden email]> wrote:
>
>
>
> > I am not storing anything in the session.
>
> > I am getting only this in the log at DEBUG level -
>
> > DEBUG 2010-10-28 17:40:57,312 [http-9090-1]
> > org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
> > Connection from DataSource
> > DEBUG 2010-10-28 17:40:57,752 [http-9090-1]
> > org.mybatis.spring.SqlSessionUtils - Creating SqlSession from
> > SqlSessionFactory
>
> > On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]> wrote:
> > > But something should be printed. I.e. this is the output of the test:
>
> > > Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
> > > package
> > > Registering MyBatis mappers
> > > Registering MyBatis mapper with 'interface
> > > org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
> > > Property 'configLocation' not specified, using default MyBatis
> > > Configuration
> > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > files specified in the config xml were loaded
> > > Property 'configLocation' not specified, using default MyBatis
> > > Configuration
> > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > files specified in the config xml were loaded
> > > Creating SqlSession from SqlSessionFactory
> > > Registering transaction synchronization for SqlSession
> > > Transaction synchronization committed SqlSession
> > > Transaction synchronization closed SqlSession
>
> > > Regarding the session..what data are you storing in your session?
>
> > > On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> > > > I have already done that but nothing in the logs.
>
> > > > One more observation - once commit stops working it never recovers for
> > > that
> > > > http session until a new http session is created. Also if one user
> > > session
> > > > gets the problem all the http session starts getting the same issue. Now
> > > if
> > > > i create a new http session then all the previous http session starts
> > > > working.
>
> > > > On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <[hidden email]
> > > >wrote:
>
> > > > > I cannot see anything wrong.
>
> > > > > Maybe you could execute your app with a logger "org.mybatis.spring"
> > > > > set to debug to see what is happening?
>
> > > > > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > > > > Here are the details, let me know if any more info is required.
>
> > > > > > Person.xml mapper file
>
> > > > > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > > > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> > > > >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > > > > <mapper namespace="com.api.Person">
> > > > > > <resultMap type="Person" id="personResultMap">
> > > > > > <id property="id" column="id" />
> > > > > > <result property="name" column="name" />
> > > > > > <result property="description" column="description" />
> > > > > > </resultMap>
>
> > > > > > <insert id="create" parameterType="Person">
> > > > > > insert into
> > > > > > person
> > > > > > (id,name,description)
> > > > > > values
> > > > > > (#{id},#{name},#{description})
> > > > > > </insert>
> > > > > > </mapper>
>
> > > > > > SqlMapConfig.xml
>
> > > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
> > > "
> > > > >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > > > > <configuration>
> > > > > > <typeAliases>
> > > > > > <typeAlias type="com.api.Person"
> > > > > > alias="Person" />
> > > > > > </typeAliases>
>
> > > > > > <mappers>
> > > > > > <mapper resource="dao/ibatis/Person.xml" />
> > > > > > </mappers>
> > > > > > </configuration>
>
> > > > > > Related spring config and also default-autowire="byName" is set.
>
> > > > > > <context:component-scan base-package="com.accept.ppm.dao">
> > > > > > <context:include-filter type="annotation"
> > > > > >             expression="org.springframework.stereotype.Repository"/>
> > > > > >     </context:component-scan>
> > > > > > <context:component-scan base-package="com.accept.ppm.service">
> > > > > > <context:include-filter type="annotation"
> > > > > > expression="org.springframework.stereotype.Component" />
> > > > > > </context:component-scan>
>
> > > > > > <bean id="sqlSession"
> > > class="org.mybatis.spring.SqlSessionFactoryBean">
> > > > > > <property name="configLocation">
> > > > > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > > > > </property>
> > > > > > <property name="dataSource">
> > > > > > <ref bean="dataSource" />
> > > > > > </property>
> > > > > > </bean>
>
> > > > > > DAO class -
>
> > > > > > public interface PersonDAO {
> > > > > > void create(Person person);
>
> > > > > > }
>
> > > > > > @Repository("personDAO")
> > > > > > public class SqlMapPersonDAO extends SqlSessionDaoSupport implements
> > > > > > PersonDAO {
> > > > > >         @Override
> > > > > > public void create(Person person) {
> > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > }
> > > > > > }
>
> > > > > > Service class -
>
> > > > > > public interface PersonService {
> > > > > > void create(Person person);
>
> > > > > > }
>
> > > > > > @Component("personService")
> > > > > > public class PersonServiceImpl extends PersonService {
> > > > > >         private PersonDAO personDAO;
>
> > > > > > public void setPersonDAO(PersonDAO personDAO) {
> > > > > > this.personDAO= personDAO;
>
> > > > > > }
>
> > > > > >         @Override
> > > > > > public void create(Person person) {
> > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > }
> > > > > > }
>
> > > > > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <
> > > [hidden email]
> > > > > >wrote:
>
> > > > > > > That config seems right. Could you post the rest of your appContext
> > > > > > > (services + mappers)?
>
> > > > > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]> wrote:
> > > > > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0
> > > on
> > > > > Apache
> > > > > > > > Tomcat 6.0.29.
>
> > > > > > > > I have used declarative transactions of spring for transaction
> > > > > > > management.
> > > > > > > > The issue is that the transactions are not working for me. The
> > > > > > > transaction
> > > > > > > > works for sometime and then suddenly stops working. I can go and
> > > do
> > > > > > > multiple
> > > > > > > > inserts and updates and all will work for 1 time or 10 time or 20
> > > > > time
> > > > > > > there
> > > > > > > > no fix patterna dn suddenly stops.
>
> > > > > > > > I even tried the annotation driven transaction but the issue is
> > > same.
> > > > > I
> > > > > > > > tried the session open and close on the template and that works
> > > but
> > > > > that
> > > > > > > > does not help as I don't to maintain transaction in my DAO layer
> > > but
> > > > > > > manage
> > > > > > > > via service layer.
>
> > > > > > > > I have tried checking all my configs but no clue. Any pointers?
>
> > > > > > > > My configurations looks like this -
>
> > > > > > > >     <tx:advice id="txAdvice"
> > > > > transaction-manager="transactionManager">
> > > > > > > >         <tx:attributes>
> > > > > > > >             <tx:method name="*" propagation="REQUIRED" />
> > > > > > > >         </tx:attributes>
> > > > > > > >     </tx:advice>
>
> > > > > > > >     <aop:config>
> > > > > > > >         <aop:pointcut id="dtxops"
> > > > > > > >             expression="execution(* com.service.*.*(..))" />
> > > > > > > >         <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops"
> > > />
> > > > > > > >     </aop:config>
>
> > > > > > > > TX Manager and DS config -
>
> > > > > > > > <bean id="transactionManager"
>
> > > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > > > > > > >         <property name="dataSource">
> > > > > > > >             <ref bean="dataSource" />
> > > > > > > >         </property>
> > > > > > > >     </bean>
>
> > > > > > > > <bean id="dataSource"
> > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean">
> > > > > > > >         <property name="resourceRef" value="true" />
> > > > > > > >         <property name="jndiName"
> > > > > value="java:comp/env/jdbc/MyDBInstance"
> > > > > > > />
> > > > > > > >     </bean>


mybatis-test.zip (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Eduardo Macarron
Thanks for the code Kamran.

I have not run it yet but this config:
        <aop:config>
                <aop:pointcut id="dtxops"
                        expression="execution(* com.accept.ppm.service.*.*(..))" />
                <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
        </aop:config>

is not in agreement with your service package
com.mybatis.test.service. Maybe it is just that you changed the code
to mail it and forgot to change that but anyway I would try it with

        <aop:config>
                <aop:pointcut id="dtxops"
                        expression="execution(* com.mybatis.test.service.*.*(..))" />
                <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
        </aop:config>

Please try it and tell us how it went.

On 29 oct, 14:28, Kamran Yadav <[hidden email]> wrote:

> I see this in the logs and there is no "Returning JDBC Connection to
> DataSource" kind of message.
>
> [10-29 16:50:00] DEBUG org.springframework.jdbc.datasource.DataSourceUtils
> [http-8080-1]: Fetching JDBC Connection from DataSource
> [10-29 16:50:00] DEBUG org.mybatis.spring.SqlSessionUtils [http-8080-1]:
> Creating SqlSession from SqlSessionFactory
> [10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: ooo Connection
> Opened
> [10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>
>  Executing: INSERT INTO person(id, name, description) VALUES(?, ?, ?)
> [10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>
> Parameters: 7(Integer), asdasds(String), asdasdas(String)
> [10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: xxx Connection
> Closed
>
> I have
>
>
>
>
>
>
>
> On Thu, Oct 28, 2010 at 7:55 PM, Hunter <[hidden email]> wrote:
> > If you never see something like the following in the debug output,
> > something is wrong:
> > DEBUG springframework.jdbc.datasource.DataSourceUtils Returning JDBC
> > Connection to DataSource
>
> > What is the code that is calling PersonService.create()? I assume it's
> > just a web request?
>
> > On Oct 28, 9:20 am, Eduardo <[hidden email]> wrote:
> > > Could you mail us some code to see if we can reproduce it?
>
> > > On 28 oct, 14:12, Kamran Yadav <[hidden email]> wrote:
>
> > > > I am not storing anything in the session.
>
> > > > I am getting only this in the log at DEBUG level -
>
> > > > DEBUG 2010-10-28 17:40:57,312 [http-9090-1]
> > > > org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
> > > > Connection from DataSource
> > > > DEBUG 2010-10-28 17:40:57,752 [http-9090-1]
> > > > org.mybatis.spring.SqlSessionUtils - Creating SqlSession from
> > > > SqlSessionFactory
>
> > > > On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]>
> > wrote:
> > > > > But something should be printed. I.e. this is the output of the test:
>
> > > > > Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
> > > > > package
> > > > > Registering MyBatis mappers
> > > > > Registering MyBatis mapper with 'interface
> > > > > org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
> > > > > Property 'configLocation' not specified, using default MyBatis
> > > > > Configuration
> > > > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > > > files specified in the config xml were loaded
> > > > > Property 'configLocation' not specified, using default MyBatis
> > > > > Configuration
> > > > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > > > files specified in the config xml were loaded
> > > > > Creating SqlSession from SqlSessionFactory
> > > > > Registering transaction synchronization for SqlSession
> > > > > Transaction synchronization committed SqlSession
> > > > > Transaction synchronization closed SqlSession
>
> > > > > Regarding the session..what data are you storing in your session?
>
> > > > > On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> > > > > > I have already done that but nothing in the logs.
>
> > > > > > One more observation - once commit stops working it never recovers
> > for
> > > > > that
> > > > > > http session until a new http session is created. Also if one user
> > > > > session
> > > > > > gets the problem all the http session starts getting the same
> > issue. Now
> > > > > if
> > > > > > i create a new http session then all the previous http session
> > starts
> > > > > > working.
>
> > > > > > On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <
> > [hidden email]
> > > > > >wrote:
>
> > > > > > > I cannot see anything wrong.
>
> > > > > > > Maybe you could execute your app with a logger
> > "org.mybatis.spring"
> > > > > > > set to debug to see what is happening?
>
> > > > > > > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > > > > > > Here are the details, let me know if any more info is required.
>
> > > > > > > > Person.xml mapper file
>
> > > > > > > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > > > > > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> > > > > > >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > > > > > > <mapper namespace="com.api.Person">
> > > > > > > > <resultMap type="Person" id="personResultMap">
> > > > > > > > <id property="id" column="id" />
> > > > > > > > <result property="name" column="name" />
> > > > > > > > <result property="description" column="description" />
> > > > > > > > </resultMap>
>
> > > > > > > > <insert id="create" parameterType="Person">
> > > > > > > > insert into
> > > > > > > > person
> > > > > > > > (id,name,description)
> > > > > > > > values
> > > > > > > > (#{id},#{name},#{description})
> > > > > > > > </insert>
> > > > > > > > </mapper>
>
> > > > > > > > SqlMapConfig.xml
>
> > > > > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > > > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config
> > 3.0//EN"
> > > > > "
> > > > > > >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > > > > > > <configuration>
> > > > > > > > <typeAliases>
> > > > > > > > <typeAlias type="com.api.Person"
> > > > > > > > alias="Person" />
> > > > > > > > </typeAliases>
>
> > > > > > > > <mappers>
> > > > > > > > <mapper resource="dao/ibatis/Person.xml" />
> > > > > > > > </mappers>
> > > > > > > > </configuration>
>
> > > > > > > > Related spring config and also default-autowire="byName" is
> > set.
>
> > > > > > > > <context:component-scan base-package="com.accept.ppm.dao">
> > > > > > > > <context:include-filter type="annotation"
>
> > expression="org.springframework.stereotype.Repository"/>
> > > > > > > >     </context:component-scan>
> > > > > > > > <context:component-scan base-package="com.accept.ppm.service">
> > > > > > > > <context:include-filter type="annotation"
> > > > > > > > expression="org.springframework.stereotype.Component" />
> > > > > > > > </context:component-scan>
>
> > > > > > > > <bean id="sqlSession"
> > > > > class="org.mybatis.spring.SqlSessionFactoryBean">
> > > > > > > > <property name="configLocation">
> > > > > > > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > > > > > > </property>
> > > > > > > > <property name="dataSource">
> > > > > > > > <ref bean="dataSource" />
> > > > > > > > </property>
> > > > > > > > </bean>
>
> > > > > > > > DAO class -
>
> > > > > > > > public interface PersonDAO {
> > > > > > > > void create(Person person);
>
> > > > > > > > }
>
> > > > > > > > @Repository("personDAO")
> > > > > > > > public class SqlMapPersonDAO extends SqlSessionDaoSupport
> > implements
> > > > > > > > PersonDAO {
> > > > > > > >         @Override
> > > > > > > > public void create(Person person) {
> > > > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > > > }
> > > > > > > > }
>
> > > > > > > > Service class -
>
> > > > > > > > public interface PersonService {
> > > > > > > > void create(Person person);
>
> > > > > > > > }
>
> > > > > > > > @Component("personService")
> > > > > > > > public class PersonServiceImpl extends PersonService {
> > > > > > > >         private PersonDAO personDAO;
>
> > > > > > > > public void setPersonDAO(PersonDAO personDAO) {
> > > > > > > > this.personDAO= personDAO;
>
> > > > > > > > }
>
> > > > > > > >         @Override
> > > > > > > > public void create(Person person) {
> > > > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > > > }
> > > > > > > > }
>
> > > > > > > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <
> > > > > [hidden email]
> > > > > > > >wrote:
>
> > > > > > > > > That config seems right. Could you post the rest of your
> > appContext
> > > > > > > > > (services + mappers)?
>
> > > > > > > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]>
> > wrote:
> > > > > > > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring
> > 1.0.0
> > > > > on
> > > > > > > Apache
> > > > > > > > > > Tomcat 6.0.29.
>
> > > > > > > > > > I have used declarative transactions of spring for
> > transaction
> > > > > > > > > management.
> > > > > > > > > > The issue is that the transactions are not working for me.
> > The
> > > > > > > > > transaction
> > > > > > > > > > works for sometime and then suddenly stops working. I can
> > go and
> > > > > do
> > > > > > > > > multiple
> > > > > > > > > > inserts and updates and all will work for 1 time or 10 time
> > or 20
> > > > > > > time
> > > > > > > > > there
> > > > > > > > > > no fix patterna dn suddenly stops.
>
> > > > > > > > > > I even tried the annotation driven transaction but the
> > issue is
> > > > > same.
> > > > > > > I
> > > > > > > > > > tried the session open and close on the template and that
> > works
> > > > > but
> > > > > > > that
> > > > > > > > > > does not help as I don't to maintain transaction in my DAO
> > layer
> > > > > but
> > > > > > > > > manage
> > > > > > > > > > via service layer.
>
> > > > > > > > > > I have tried checking all my configs but no clue. Any
> > pointers?
>
> > > > > > > > > > My configurations looks like this -
>
> > > > > > > > > >     <tx:advice id="txAdvice"
> > > > > > > transaction-manager="transactionManager">
> > > > > > > > > >         <tx:attributes>
> > > > > > > > > >             <tx:method name="*" propagation="REQUIRED" />
> > > > > > > > > >         </tx:attributes>
> > > > > > > > > >     </tx:advice>
>
> > > > > > > > > >     <aop:config>
> > > > > > > > > >         <aop:pointcut id="dtxops"
> > > > > > > > > >             expression="execution(* com.service.*.*(..))"
> > />
> > > > > > > > > >         <aop:advisor advice-ref="txAdvice"
> > pointcut-ref="dtxops"
> > > > > />
> > > > > > > > > >     </aop:config>
>
> > > > > > > > > > TX Manager and DS config -
>
> > > > > > > > > > <bean id="transactionManager"
>
> > class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
> > > > > > > > > >         <property name="dataSource">
> > > > > > > > > >             <ref bean="dataSource" />
> > > > > > > > > >         </property>
> > > > > > > > > >     </bean>
>
> > > > > > > > > > <bean id="dataSource"
>
> ...
>
> leer más »
>
>  mybatis-test.zip
> 15 KVerDescargar
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Eduardo Macarron
I have runned it in glassfish and mysql and it worked fine... seems
that there is no problem with transactions.

I ran it with mybatis-spring.1.0.0-RC1 and dwr-3.0.M1.jar but I
suppose your versions wil work fine as well.


On 29 oct, 18:29, Eduardo <[hidden email]> wrote:

> Thanks for the code Kamran.
>
> I have not run it yet but this config:
>         <aop:config>
>                 <aop:pointcut id="dtxops"
>                         expression="execution(* com.accept.ppm.service.*.*(..))" />
>                 <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
>         </aop:config>
>
> is not in agreement with your service package
> com.mybatis.test.service. Maybe it is just that you changed the code
> to mail it and forgot to change that but anyway I would try it with
>
>         <aop:config>
>                 <aop:pointcut id="dtxops"
>                         expression="execution(* com.mybatis.test.service.*.*(..))" />
>                 <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
>         </aop:config>
>
> Please try it and tell us how it went.
>
> On 29 oct, 14:28, Kamran Yadav <[hidden email]> wrote:
>
>
>
>
>
>
>
> > I see this in the logs and there is no "Returning JDBC Connection to
> > DataSource" kind of message.
>
> > [10-29 16:50:00] DEBUG org.springframework.jdbc.datasource.DataSourceUtils
> > [http-8080-1]: Fetching JDBC Connection from DataSource
> > [10-29 16:50:00] DEBUG org.mybatis.spring.SqlSessionUtils [http-8080-1]:
> > Creating SqlSession from SqlSessionFactory
> > [10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: ooo Connection
> > Opened
> > [10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>
> >  Executing: INSERT INTO person(id, name, description) VALUES(?, ?, ?)
> > [10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>
> > Parameters: 7(Integer), asdasds(String), asdasdas(String)
> > [10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: xxx Connection
> > Closed
>
> > I have
>
> > On Thu, Oct 28, 2010 at 7:55 PM, Hunter <[hidden email]> wrote:
> > > If you never see something like the following in the debug output,
> > > something is wrong:
> > > DEBUG springframework.jdbc.datasource.DataSourceUtils Returning JDBC
> > > Connection to DataSource
>
> > > What is the code that is calling PersonService.create()? I assume it's
> > > just a web request?
>
> > > On Oct 28, 9:20 am, Eduardo <[hidden email]> wrote:
> > > > Could you mail us some code to see if we can reproduce it?
>
> > > > On 28 oct, 14:12, Kamran Yadav <[hidden email]> wrote:
>
> > > > > I am not storing anything in the session.
>
> > > > > I am getting only this in the log at DEBUG level -
>
> > > > > DEBUG 2010-10-28 17:40:57,312 [http-9090-1]
> > > > > org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
> > > > > Connection from DataSource
> > > > > DEBUG 2010-10-28 17:40:57,752 [http-9090-1]
> > > > > org.mybatis.spring.SqlSessionUtils - Creating SqlSession from
> > > > > SqlSessionFactory
>
> > > > > On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]>
> > > wrote:
> > > > > > But something should be printed. I.e. this is the output of the test:
>
> > > > > > Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
> > > > > > package
> > > > > > Registering MyBatis mappers
> > > > > > Registering MyBatis mapper with 'interface
> > > > > > org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
> > > > > > Property 'configLocation' not specified, using default MyBatis
> > > > > > Configuration
> > > > > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > > > > files specified in the config xml were loaded
> > > > > > Property 'configLocation' not specified, using default MyBatis
> > > > > > Configuration
> > > > > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > > > > files specified in the config xml were loaded
> > > > > > Creating SqlSession from SqlSessionFactory
> > > > > > Registering transaction synchronization for SqlSession
> > > > > > Transaction synchronization committed SqlSession
> > > > > > Transaction synchronization closed SqlSession
>
> > > > > > Regarding the session..what data are you storing in your session?
>
> > > > > > On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> > > > > > > I have already done that but nothing in the logs.
>
> > > > > > > One more observation - once commit stops working it never recovers
> > > for
> > > > > > that
> > > > > > > http session until a new http session is created. Also if one user
> > > > > > session
> > > > > > > gets the problem all the http session starts getting the same
> > > issue. Now
> > > > > > if
> > > > > > > i create a new http session then all the previous http session
> > > starts
> > > > > > > working.
>
> > > > > > > On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <
> > > [hidden email]
> > > > > > >wrote:
>
> > > > > > > > I cannot see anything wrong.
>
> > > > > > > > Maybe you could execute your app with a logger
> > > "org.mybatis.spring"
> > > > > > > > set to debug to see what is happening?
>
> > > > > > > > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > > > > > > > Here are the details, let me know if any more info is required.
>
> > > > > > > > > Person.xml mapper file
>
> > > > > > > > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > > > > > > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> > > > > > > >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > > > > > > > <mapper namespace="com.api.Person">
> > > > > > > > > <resultMap type="Person" id="personResultMap">
> > > > > > > > > <id property="id" column="id" />
> > > > > > > > > <result property="name" column="name" />
> > > > > > > > > <result property="description" column="description" />
> > > > > > > > > </resultMap>
>
> > > > > > > > > <insert id="create" parameterType="Person">
> > > > > > > > > insert into
> > > > > > > > > person
> > > > > > > > > (id,name,description)
> > > > > > > > > values
> > > > > > > > > (#{id},#{name},#{description})
> > > > > > > > > </insert>
> > > > > > > > > </mapper>
>
> > > > > > > > > SqlMapConfig.xml
>
> > > > > > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > > > > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config
> > > 3.0//EN"
> > > > > > "
> > > > > > > >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > > > > > > > <configuration>
> > > > > > > > > <typeAliases>
> > > > > > > > > <typeAlias type="com.api.Person"
> > > > > > > > > alias="Person" />
> > > > > > > > > </typeAliases>
>
> > > > > > > > > <mappers>
> > > > > > > > > <mapper resource="dao/ibatis/Person.xml" />
> > > > > > > > > </mappers>
> > > > > > > > > </configuration>
>
> > > > > > > > > Related spring config and also default-autowire="byName" is
> > > set.
>
> > > > > > > > > <context:component-scan base-package="com.accept.ppm.dao">
> > > > > > > > > <context:include-filter type="annotation"
>
> > > expression="org.springframework.stereotype.Repository"/>
> > > > > > > > >     </context:component-scan>
> > > > > > > > > <context:component-scan base-package="com.accept.ppm.service">
> > > > > > > > > <context:include-filter type="annotation"
> > > > > > > > > expression="org.springframework.stereotype.Component" />
> > > > > > > > > </context:component-scan>
>
> > > > > > > > > <bean id="sqlSession"
> > > > > > class="org.mybatis.spring.SqlSessionFactoryBean">
> > > > > > > > > <property name="configLocation">
> > > > > > > > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > > > > > > > </property>
> > > > > > > > > <property name="dataSource">
> > > > > > > > > <ref bean="dataSource" />
> > > > > > > > > </property>
> > > > > > > > > </bean>
>
> > > > > > > > > DAO class -
>
> > > > > > > > > public interface PersonDAO {
> > > > > > > > > void create(Person person);
>
> > > > > > > > > }
>
> > > > > > > > > @Repository("personDAO")
> > > > > > > > > public class SqlMapPersonDAO extends SqlSessionDaoSupport
> > > implements
> > > > > > > > > PersonDAO {
> > > > > > > > >         @Override
> > > > > > > > > public void create(Person person) {
> > > > > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > > > > }
> > > > > > > > > }
>
> > > > > > > > > Service class -
>
> > > > > > > > > public interface PersonService {
> > > > > > > > > void create(Person person);
>
> > > > > > > > > }
>
> > > > > > > > > @Component("personService")
> > > > > > > > > public class PersonServiceImpl extends PersonService {
> > > > > > > > >         private PersonDAO personDAO;
>
> > > > > > > > > public void setPersonDAO(PersonDAO personDAO) {
> > > > > > > > > this.personDAO= personDAO;
>
> > > > > > > > > }
>
> > > > > > > > >         @Override
> > > > > > > > > public void create(Person person) {
> > > > > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > > > > }
> > > > > > > > > }
>
> > > > > > > > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <
> > > > > > [hidden email]
> > > > > > > > >wrote:
>
> > > > > > > > > > That config seems right. Could you post the rest of your
> > > appContext
> > > > > > > > > > (services + mappers)?
>
> > > > > > > > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]>
> > > wrote:
> > > > > > > > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring
> > > 1.0.0
> > > > > > on
> > > > > > > > Apache
> > > > > > > > > > > Tomcat 6.0.29.
>
> > > > > > > > > > > I have used declarative transactions of spring for
> > > transaction
> > > > > > > > > > management.
> > > > > > > > > > > The issue is that the transactions are not working for me.
> > > The
> > > > > > > > > > transaction
> > > > > > > > > > > works for sometime and then suddenly stops working. I can
> > > go and
> > > > > > do
> > > > > > > > > > multiple
> > > > > > > > > > > inserts and updates and all will work for 1 time or 10 time
> > > or 20
> > > > > > > > time
> > > > > > > > > > there
> > > > > > > > > > > no fix patterna dn suddenly stops.
>
> > > > > > > > > > > I even tried the annotation driven transaction but the
> > > issue is
> > > > > > same.
> > > > > > > > I
> > > > > > > > > > > tried the session open and close on the template and that
> > > works
> > > > > > but
> > > > > > > > that
>
> ...
>
> leer más »
Reply | Threaded
Open this post in threaded view
|

Re: Spring aop transaction not committing the transaction with mybatis

Hunter
I ran it in Jetty, modified to use hsqldb and didn't see any problems
either other than the one Eduardo pointed out.

You can use the following config in log4j:
log4j.logger.org.apache.ibatis=INFO
log4j.logger.org.mybatis.spring=DEBUG
log4j.logger.java.sql=DEBUG
log4j.logger.org.springframework.jdbc=DEBUG

You should see something like:
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceTransactionManager
[main]: Creating new transaction with name
[com.mybatis.test.service.impl.PersonServiceImpl.create]:
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.SimpleDriverDataSource [main]:
Creating new JDBC Driver Connection to [jdbc:hsqldb:mem:dataSource]
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceTransactionManager
[main]: Acquired Connection [org.hsqldb.jdbc.jdbcConnection@8dc1f04]
for JDBC transaction
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceTransactionManager
[main]: Switching JDBC Connection
[org.hsqldb.jdbc.jdbcConnection@8dc1f04] to manual commit
[10-29 16:25:57] DEBUG org.mybatis.spring.SqlSessionUtils [main]:
Creating SqlSession from SqlSessionFactory
[10-29 16:25:57] DEBUG java.sql.Connection [main]: ooo Connection
Opened
[10-29 16:25:57] DEBUG org.mybatis.spring.SqlSessionUtils [main]:
Registering transaction synchronization for SqlSession
[10-29 16:25:57] DEBUG java.sql.PreparedStatement [main]: ==>
Executing: INSERT INTO person(id, name, description) VALUES(?, ?, ?)
[10-29 16:25:57] DEBUG java.sql.PreparedStatement [main]: ==>
Parameters: 820511(Integer), 375a4629(String), test 820511(String)
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceTransactionManager
[main]: Initiating transaction commit
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceTransactionManager
[main]: Committing JDBC transaction on Connection
[org.hsqldb.jdbc.jdbcConnection@8dc1f04]
[10-29 16:25:57] DEBUG org.mybatis.spring.SqlSessionUtils [main]:
Transaction synchronization committed SqlSession
[10-29 16:25:57] DEBUG org.mybatis.spring.SqlSessionUtils [main]:
Transaction synchronization closed SqlSession
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceTransactionManager
[main]: Releasing JDBC Connection
[org.hsqldb.jdbc.jdbcConnection@8dc1f04] after transaction
[10-29 16:25:57] DEBUG
org.springframework.jdbc.datasource.DataSourceUtils [main]: Returning
JDBC Connection to DataSource


On Oct 29, 3:43 pm, Eduardo <[hidden email]> wrote:

> I have runned it in glassfish and mysql and it worked fine... seems
> that there is no problem with transactions.
>
> I ran it with mybatis-spring.1.0.0-RC1 and dwr-3.0.M1.jar but I
> suppose your versions wil work fine as well.
>
> On 29 oct, 18:29, Eduardo <[hidden email]> wrote:
>
>
>
> > Thanks for the code Kamran.
>
> > I have not run it yet but this config:
> >         <aop:config>
> >                 <aop:pointcut id="dtxops"
> >                         expression="execution(* com.accept.ppm.service.*.*(..))" />
> >                 <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
> >         </aop:config>
>
> > is not in agreement with your service package
> > com.mybatis.test.service. Maybe it is just that you changed the code
> > to mail it and forgot to change that but anyway I would try it with
>
> >         <aop:config>
> >                 <aop:pointcut id="dtxops"
> >                         expression="execution(* com.mybatis.test.service.*.*(..))" />
> >                 <aop:advisor advice-ref="txAdvice" pointcut-ref="dtxops" />
> >         </aop:config>
>
> > Please try it and tell us how it went.
>
> > On 29 oct, 14:28, Kamran Yadav <[hidden email]> wrote:
>
> > > I see this in the logs and there is no "Returning JDBC Connection to
> > > DataSource" kind of message.
>
> > > [10-29 16:50:00] DEBUG org.springframework.jdbc.datasource.DataSourceUtils
> > > [http-8080-1]: Fetching JDBC Connection from DataSource
> > > [10-29 16:50:00] DEBUG org.mybatis.spring.SqlSessionUtils [http-8080-1]:
> > > Creating SqlSession from SqlSessionFactory
> > > [10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: ooo Connection
> > > Opened
> > > [10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>
> > >  Executing: INSERT INTO person(id, name, description) VALUES(?, ?, ?)
> > > [10-29 16:50:00] DEBUG java.sql.PreparedStatement [http-8080-1]: ==>
> > > Parameters: 7(Integer), asdasds(String), asdasdas(String)
> > > [10-29 16:50:00] DEBUG java.sql.Connection [http-8080-1]: xxx Connection
> > > Closed
>
> > > I have
>
> > > On Thu, Oct 28, 2010 at 7:55 PM, Hunter <[hidden email]> wrote:
> > > > If you never see something like the following in the debug output,
> > > > something is wrong:
> > > > DEBUG springframework.jdbc.datasource.DataSourceUtils Returning JDBC
> > > > Connection to DataSource
>
> > > > What is the code that is calling PersonService.create()? I assume it's
> > > > just a web request?
>
> > > > On Oct 28, 9:20 am, Eduardo <[hidden email]> wrote:
> > > > > Could you mail us some code to see if we can reproduce it?
>
> > > > > On 28 oct, 14:12, Kamran Yadav <[hidden email]> wrote:
>
> > > > > > I am not storing anything in the session.
>
> > > > > > I am getting only this in the log at DEBUG level -
>
> > > > > > DEBUG 2010-10-28 17:40:57,312 [http-9090-1]
> > > > > > org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
> > > > > > Connection from DataSource
> > > > > > DEBUG 2010-10-28 17:40:57,752 [http-9090-1]
> > > > > > org.mybatis.spring.SqlSessionUtils - Creating SqlSession from
> > > > > > SqlSessionFactory
>
> > > > > > On Thu, Oct 28, 2010 at 5:33 PM, Eduardo <[hidden email]>
> > > > wrote:
> > > > > > > But something should be printed. I.e. this is the output of the test:
>
> > > > > > > Searching for MyBatis mappers in 'org.mybatis.spring.sample.mapper'
> > > > > > > package
> > > > > > > Registering MyBatis mappers
> > > > > > > Registering MyBatis mapper with 'interface
> > > > > > > org.mybatis.spring.sample.mapper.UserMapper' mapperInterface
> > > > > > > Property 'configLocation' not specified, using default MyBatis
> > > > > > > Configuration
> > > > > > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > > > > > files specified in the config xml were loaded
> > > > > > > Property 'configLocation' not specified, using default MyBatis
> > > > > > > Configuration
> > > > > > > Property 'mapperLocations' was not specified, only MyBatis mapper
> > > > > > > files specified in the config xml were loaded
> > > > > > > Creating SqlSession from SqlSessionFactory
> > > > > > > Registering transaction synchronization for SqlSession
> > > > > > > Transaction synchronization committed SqlSession
> > > > > > > Transaction synchronization closed SqlSession
>
> > > > > > > Regarding the session..what data are you storing in your session?
>
> > > > > > > On 28 oct, 09:08, Kamran Yadav <[hidden email]> wrote:
> > > > > > > > I have already done that but nothing in the logs.
>
> > > > > > > > One more observation - once commit stops working it never recovers
> > > > for
> > > > > > > that
> > > > > > > > http session until a new http session is created. Also if one user
> > > > > > > session
> > > > > > > > gets the problem all the http session starts getting the same
> > > > issue. Now
> > > > > > > if
> > > > > > > > i create a new http session then all the previous http session
> > > > starts
> > > > > > > > working.
>
> > > > > > > > On Thu, Oct 28, 2010 at 12:11 PM, Eduardo <
> > > > [hidden email]
> > > > > > > >wrote:
>
> > > > > > > > > I cannot see anything wrong.
>
> > > > > > > > > Maybe you could execute your app with a logger
> > > > "org.mybatis.spring"
> > > > > > > > > set to debug to see what is happening?
>
> > > > > > > > > On 28 oct, 08:34, Kamran Yadav <[hidden email]> wrote:
> > > > > > > > > > Here are the details, let me know if any more info is required.
>
> > > > > > > > > > Person.xml mapper file
>
> > > > > > > > > > <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> > > > > > > > > > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "
> > > > > > > > >http://mybatis.org/dtd/mybatis-3-mapper.dtd">
> > > > > > > > > > <mapper namespace="com.api.Person">
> > > > > > > > > > <resultMap type="Person" id="personResultMap">
> > > > > > > > > > <id property="id" column="id" />
> > > > > > > > > > <result property="name" column="name" />
> > > > > > > > > > <result property="description" column="description" />
> > > > > > > > > > </resultMap>
>
> > > > > > > > > > <insert id="create" parameterType="Person">
> > > > > > > > > > insert into
> > > > > > > > > > person
> > > > > > > > > > (id,name,description)
> > > > > > > > > > values
> > > > > > > > > > (#{id},#{name},#{description})
> > > > > > > > > > </insert>
> > > > > > > > > > </mapper>
>
> > > > > > > > > > SqlMapConfig.xml
>
> > > > > > > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > > > > > > <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config
> > > > 3.0//EN"
> > > > > > > "
> > > > > > > > >http://mybatis.org/dtd/mybatis-3-config.dtd">
> > > > > > > > > > <configuration>
> > > > > > > > > > <typeAliases>
> > > > > > > > > > <typeAlias type="com.api.Person"
> > > > > > > > > > alias="Person" />
> > > > > > > > > > </typeAliases>
>
> > > > > > > > > > <mappers>
> > > > > > > > > > <mapper resource="dao/ibatis/Person.xml" />
> > > > > > > > > > </mappers>
> > > > > > > > > > </configuration>
>
> > > > > > > > > > Related spring config and also default-autowire="byName" is
> > > > set.
>
> > > > > > > > > > <context:component-scan base-package="com.accept.ppm.dao">
> > > > > > > > > > <context:include-filter type="annotation"
>
> > > > expression="org.springframework.stereotype.Repository"/>
> > > > > > > > > >     </context:component-scan>
> > > > > > > > > > <context:component-scan base-package="com.accept.ppm.service">
> > > > > > > > > > <context:include-filter type="annotation"
> > > > > > > > > > expression="org.springframework.stereotype.Component" />
> > > > > > > > > > </context:component-scan>
>
> > > > > > > > > > <bean id="sqlSession"
> > > > > > > class="org.mybatis.spring.SqlSessionFactoryBean">
> > > > > > > > > > <property name="configLocation">
> > > > > > > > > > <value>classpath:/dao/ibatis/SqlMapConfig.xml</value>
> > > > > > > > > > </property>
> > > > > > > > > > <property name="dataSource">
> > > > > > > > > > <ref bean="dataSource" />
> > > > > > > > > > </property>
> > > > > > > > > > </bean>
>
> > > > > > > > > > DAO class -
>
> > > > > > > > > > public interface PersonDAO {
> > > > > > > > > > void create(Person person);
>
> > > > > > > > > > }
>
> > > > > > > > > > @Repository("personDAO")
> > > > > > > > > > public class SqlMapPersonDAO extends SqlSessionDaoSupport
> > > > implements
> > > > > > > > > > PersonDAO {
> > > > > > > > > >         @Override
> > > > > > > > > > public void create(Person person) {
> > > > > > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > > > > > }
> > > > > > > > > > }
>
> > > > > > > > > > Service class -
>
> > > > > > > > > > public interface PersonService {
> > > > > > > > > > void create(Person person);
>
> > > > > > > > > > }
>
> > > > > > > > > > @Component("personService")
> > > > > > > > > > public class PersonServiceImpl extends PersonService {
> > > > > > > > > >         private PersonDAO personDAO;
>
> > > > > > > > > > public void setPersonDAO(PersonDAO personDAO) {
> > > > > > > > > > this.personDAO= personDAO;
>
> > > > > > > > > > }
>
> > > > > > > > > >         @Override
> > > > > > > > > > public void create(Person person) {
> > > > > > > > > > SqlSessionTemplate template = getSqlSessionTemplate();
> > > > > > > > > > template.insert("com.api.Person.create", person);
>
> > > > > > > > > > }
> > > > > > > > > > }
>
> > > > > > > > > > On Thu, Oct 28, 2010 at 10:34 AM, Eduardo <
> > > > > > > [hidden email]
> > > > > > > > > >wrote:
>
> > > > > > > > > > > That config seems right. Could you post the rest of your
> > > > appContext
> > > > > > > > > > > (services + mappers)?
>
> > > > > > > > > > > On 28 oct, 05:09, Kamran Yadav <[hidden email]>
> > > > wrote:
> > > > > > > > > > > > I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring
> > > > 1.0.0
> > > > > > > on
> > > > > > > > > Apache
>
> ...
>
> read more »