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 6890233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:15:22+00:00 2026-05-27T06:15:22+00:00

I wanted to set the transactionManager based on some input criteria and hence I

  • 0

I wanted to set the transactionManager based on some input criteria and hence I moved from declarative to programmatic transaction management .

something like

public User saveUser(NewUser newUser){

     return transactionTemplate.execute(new TransactionCallback() {
              // the code in this method executes in a transactional context
              public Object doInTransaction(TransactionStatus status) {
                  try {
                        User savedObj = someService.saveUser(newUser);
        return savedObj ;
                } catch (DataManagerAPIException e) {
                    throw new RuntimeException(e);
                }
              }
            });
 }

Everything works fine but wrapping every service call (our transaction boundary is at the GWT client service level.Something like UI–>Client Service–>Service–>Dao) with a Transaction callback is making the code bit of a mess compared to @Transactional . Can there be an easier way to do this ? Maybe an AOP based approach ?

I tried the following

//Wrap every Client service method with a transaction.

@Around("execution(* com.myProject.server.service.*.*(..))")
public void transactionManagerProviderResult(final ProceedingJoinPoint pjp) {

    transactionTemplate.execute(new TransactionCallback() {

        @Override
        public Object doInTransaction(TransactionStatus status) {
            try {
                            Object result = pjp.proceed();
            return result ;
            } catch (Throwable e) {
                e.printStackTrace();
                return null;
            }
        }
    });
}

The code runs fine inside the transactional context and the ‘result ‘ contains the right value(The newly saved user) but the caller of the saveUser method(GWT Widget layer) always gets a null object . This is not an issue with GWT since I tried it independent of GWT also . Everything seems to be fine till ‘result’ . After this the Object is lost. What could be the possible reason and solution for the issue?

  • 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-27T06:15:22+00:00Added an answer on May 27, 2026 at 6:15 am

    The caller gets a null object because you don’t return anything from your method:

    public Object transactionManagerProviderResult(final ProceedingJoinPoint pjp) {
        return transactionTemplate.execute(new TransactionCallback() {
            // ...
    

    It’s not very clear why you need to do this yourself instead of letting the @Transactional Spring support do it for you.

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

Sidebar

Related Questions

I wanted to use a hashtable as set of some objects for a graphic
I wanted to be able to set the keyEquivalent of an NSMenuItem based on
I wanted to set some handler for all the unexpected exceptions that I might
I wanted to set up remote debugging from Eclipse. Tomcat is running as a
I wanted to set a value of BrowsableAttribute for some of MyClass instance's properties
I'm using Sinatra, and I wanted to set up some of the convenience rake
I wanted to set up a simple data communication between two C# applications, and
I set up a new webapp Maven project and wanted to test it with
I set up a Zend Framework application using Zend_Tool, but I wanted multiple modules
We have a multi-store set up and I wanted to change the template slightly

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.