Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

pointcut and @Transactional confusion

 
Kousik Majumder
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a confusion over spring transaction manager. I have below code in my spring bean xml as part of transactional manager. Do I still need to provide @Transactional in the target class(CacheTest in this case) ?
What I understand is this is either or situation. Either I can provide all in xml or I can go with annotation based. Right?





Thanks,
Kousik
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

By the documentation, the AOP can handle by itself the transactions. Maybe the problem you have is that a non-Spring container beans is trying to use the Transactions, and there is other approach for that:

http://docs.spring.io/spring/docs/3.1.x/spring-framework-reference/html/aop.html (8.8.2 Other Spring aspects for AspectJ)
http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#transaction-declarative (10.5.9 Using @Transactional with AspectJ )
http://stackoverflow.com/questions/2192410/how-to-set-springframework-transactional-with-aspectj

Also, I think this thread would fit in https://coderanch.com/forums/f-96/Spring forum (and not in Java EE forum)

Regards
 
Kousik Majumder
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply Luan. What I have understood is that it is not mandatory to put @Transactional in the class along with xml configuration file. Am I right?
Please correct me if I am wrong.
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You are right, the AOP can make the transaction available using weaving, so the annotation would be superfluous. I was about to create an example but I found this one http://simplespringtutorial.com/springDeclarativeTransactions.html . Note that you can use the source code to test using only the annotation (which is already coded) or with AOP (which needs to follows the changes cited in the same web page).

Regards =)
 
See where your hand is? Not there. It's next to this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!