Results 1 to 4 of 4

Thread: How to make transactions span multiple DAO-ops?

  1. #1
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default How to make transactions span multiple DAO-ops?

    Hi!

    This is a question about DAOs, business objects and how to make their (i.e the business objects) transaction-safe.

    One of the Spring distribution samples contains a LogicFacade backed up by a LogicFacadeImpl which is regarded as the primary (and only) business object. Transactions works well, no problems there, and I'm even beginning to understand some of the mechanisms behind it.

    However, I've been searching for information regarding the use of BOs from a transactional point of view. My idea is to limit the number of methods in the DAO, maybe CRUDs only and to make the DAO member of a BO, and then invoking its DAO member. One reason for this is mr Johnson's advice in his "J2EE Dev. wo EJB" to avoid large "God objects" like for example LogicFacade.

    My question is; is it possible to make a construct like
    Code:
    public Object invoke(Object command){
    
    	getDao().performDBOperation();
    	//etc
    	//etc
    	getDao().performAnotherDBOperation();
    	.
    	.
    
    }
    transactional, ie if 'performAnotherDBOperation' fails, 'performDBOperation' is rolled back?

    Of course both DB-operation have their individual transaction safeness, but how do I make them work as a "team"?

    I hope my question is understandable.

    Thanks!
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  2. #2

    Default

    It happens automatically if the "invoke" method uses a transaction attribute like PROPAGATION_REQUIRED. Basically, if either DAO method throws an exception, the whole thing rolls back.

  3. #3
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    Thanks!


    :roll:
    I'm just stupid, of course transactions must involve a TxManager of some kind...duh!

    But; can you use the same TxManager for many transactions. I understand that each business object must have its own TransactionProxyFactoryBean... is this correct?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  4. #4

    Default

    Correct. All TransactionProxyFactoryBeans can refer to the same transaction manager.

Similar Threads

  1. JDO Transactions and JUnit testing
    By markds75 in forum Data
    Replies: 2
    Last Post: Sep 17th, 2005, 01:46 AM
  2. Replies: 4
    Last Post: May 19th, 2005, 05:35 AM
  3. Multiple Pages
    By afida in forum Swing
    Replies: 12
    Last Post: Feb 16th, 2005, 08:42 AM
  4. Grouping multiple SqlUpdates into transactions
    By compostellas in forum Data
    Replies: 5
    Last Post: Oct 11th, 2004, 07:57 PM
  5. Replies: 4
    Last Post: Sep 10th, 2004, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •