Results 1 to 3 of 3

Thread: AOP sping Transaction in service layer

  1. #1

    Default AOP sping Transaction in service layer

    Hi all,

    I am trying to use spring AOP for transaction support in service layer, but it's not working please provide me the solution.

    In my application i am using spring and hibernate.
    following steps i have done to implement the transaction if i have missed any thing please guide me.

    class PersonServiceProvider{
    public void createPerson(...){
    .....
    calling the persistence layer for storing
    eg personPersistence.save(..);
    addressPersistence.save();
    }
    }

    in each persistence layer am using the hibernate transaction for saving the data.
    and xml configuration is
    <tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
    <tx:method name="createPerson*" rollback-for="Throwable" propagation="NESTED"/>
    </tx:attributes>
    </tx:advice>

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

    when an exception is raised in middle of PersonServiceProvider createPerson() method it's not rollbacking the data.
    what should i need to rollback the data if an exception is raised.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Please use [ code][/code ] tags when posting code that way it remains readable.

    Issues with transactions and the setup have been answered numerous times before so please use the forum search.

    MOst commonly

    1. Duplicate component-scanning leading to proxied and non proxied instances (see also 2).
    2. Wrong transaction setup (beans in root context, tx config in child context or vice-versa)
    3. Non-transactional database (MySQL with ISAM tables)
    4. Expecting non spring managed beans to be transactional
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Hi all,

    I tried AOP transaction in stand alone application its working, but its not working in web application.
    Can any one suggest me. I followed same approach for both the ways.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •