Sign Up

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

Have an account? Sign In

Have an account? Sign In Now

Sign In

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

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

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

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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

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

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

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

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

Mobile menu

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:21:04+00:00 2026-05-23T13:21:04+00:00

We are using Spring+JPA for our RESTful web services application. This is a high

  • 0

We are using Spring+JPA for our RESTful web services application. This is a high transactional application and performs plenty of CRUD operations.

I am using @Transaction annotation on methods to perform the transaction and all is working fine.

I was just wondering if the Transaction can be managed outside the class in the configuration file based on pattern matching, i.e. all methods starting with add/update/delete can automatically be Transaction enabled (without the use of @Transaction annotation)?

Could someone please confirm if that’s possible?

If ‘Yes’ please provide me with some web link or example.

Thanks.

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

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:21:04+00:00Added an answer on May 23, 2026 at 1:21 pm

    Of course! In fact this was the only possible solution before Java 5 and @Transactional annotation. Look at 10.5.2 Example of declarative transaction implementation in Spring documentation. There you will find examples of transaction demarcation configuration via XML and AspectJ pointcuts.

    This is a simple configuration excerpt from the documentation pointed above:

    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource">
            <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
                <!-- ... -->
            </bean>
        </property>
    </bean>
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>
    
    <aop:config>
        <aop:pointcut id="fooServiceOperation" expression="execution(* x.y.service.FooService.*(..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"/>
    </aop:config>
    

    As you can see, all methods with name prefixed with get are marked as read-only, while all other methods of FooService (x.y.service.FooService.*(..)) pointcut) are transactional and not read-only.

    As you can see using more verbose XML syntax gives you some great benefits like declarative and more flexible transaction demarcation, mainly thanks to AspectJ syntax (make sure to learn it first).

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

Sidebar

Related Questions

I have a web application using JPA and JTA with Spring. I would like
My web application is using Java, Hibernate's JPA implementation (EntityManager) and Spring. What are
I am developping a web application using Spring (3.1.x), JSF 2, JPA 2 (Hibernate
I am using Spring Forms for my web application. For nested properties, the form
I am using spring,JPA,jsf for my application and webserver is tomcat.In my application i
I build j2ee application using spring, hibernage-JPA and c3p0 for connection pool. I have
I am building a new web app and I am using Spring, JPA/Hibernate, and
Our web project uses spring3, Jpa (hibernate). To save CRUD and other commonly used
We are using JPA entity beans as our model for Spring MVC controller on
I am developing an application using SPRING 3.0.4, JPA 2, Hibernate 3.5.5. I an

Explore

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

Footer

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

Insert/edit link

Enter the destination URL

Or link to existing content

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