• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

AOP sping Transaction in service layer

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you need
 
Madhava Reddy Solipuram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Boswell wrote:I think you need



Thanks for your quick replay.
I tried that also but no change when an exception is raised data is not rollbacking.
 
Madhava Reddy Solipuram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Madhava Reddy Solipuram
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is handling the exceptions in service layer. After removing try catch transaction worked normally
 
My, my, aren't you a big fella. Here, have a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic