users
[Top] [All Lists]

Declarative Spring Transaction Question

To: <users@xxxxxxxxxx>
Subject: Declarative Spring Transaction Question
From: "Abraham Fathman" <abraham@xxxxxxxxxxx>
Date: Wed, 30 Mar 2005 14:08:45 -0500
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Thread-index: AcU1W+VgcI0Shgb8Q3u6xeP0Gf1rNw==
I have a question regarding declarative spring transactions. I have been
using source level metadata to declare which methods should have
transactions around them for example:

  /**
   *
@@org.springframework.transaction.interceptor.RuleBasedTransactionAttribute(
)
   * @@org.springframework.transaction.interceptor.RollbackRuleAttribute
(Throwable.class)
   */ 
  public void dummyTest()
  {
    otherObject.dummyTest1(); 
    otherObject.dummyTest2();
  }

And this has been working great... Well I just noticed that it doesn't work
quite the way that I originally hoped. That is, if I add a second method,
otherMethod(), that would call dummyTest(). When otherMethod is ran,
dummyTest is not ran in a transaction.

  public void otherMethod()
  {
    // Do some work that has nothing to do with needing a transaction
    ...
    // Optionally run the dummyTest method
    if ( option )
      dummyTest()
  }


At first I was surprised by this but the more that I think about it it makes
sense... Since I am not going through the AOP Proxy to make the call to the
other dummyTest.

I didn't see anything in the spring docs that mention this (in the
transaction section, maybe in the AOP Section?). Something else not
mentioned but it should almost be forced that transactions would always be
around public methods (If what I have state above is actually true)...

Am I experiencing the expected behavior? 
Are other people working around this somehow?

Anyway to call other methods in your class through the proxy object?
(Gracefully?)

Thanks for your feedback,

Abraham Fathman


<Prev in Thread] Current Thread [Next in Thread>
  • Declarative Spring Transaction Question, Abraham Fathman <=