Announcement Announcement Module
Collapse
No announcement yet.
@Transaction - Bug or Feature? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Transaction - Bug or Feature?

    Hi,

    I am using annotations to configure my applications transactions. I have a service class that iterates through a list of objects and executes some updates, inserts and deletes.

    The call stack is like:

    void process() throws Exception; (propagation not required)
    List<Object> getObjects(); (propagation read_only)
    void execute(Object object) (propagation requires_new)

    The execute requires a new transaction because I want the individual objects to be committed/rolled back independently). However they are all being rolled back or committed.

    The funny thing is if I move the process method to another class and start the work flow from it as opposed to in the same class as the other methods the transactions are committed or rolled back independently. I dont know why the propagation not required is not working on that method.

    My question is, when using annotation driven transaction demarcation it almost seems like if you use @Transaction on one method the entire class becomes transactional. Could that be possible? Or am I just not getting the propagation levels on each method right?

    Thanks!

  • #2
    Spring transactions are built on top of AOP. Spring AOP doesn't advise self-invocations (6.6.1. Understanding AOP proxies)

    I already posted an example how to use aspectj to inject transactions - @Transactional methods simulated with inner class

    Comment


    • #3
      Good post, thank you sir.

      Comment

      Working...
      X