Discussions

EJB design: Where to put Transactions?

  1. Where to put Transactions? (3 messages)

    We are going to devleop a project, in J2ee, in that we are using DAO pattern,
    we are using session beans for EJB and DAO class for Data Access,
    So in that case where i have to implement Transactions, in session bean or
    in DAO , pls reply with an ideal exampl, it is important.

    Threaded Messages (3)

  2. Where to put Transactions?[ Go to top ]

    As a rule of thumb, I would put all transaction demarcation at one layer, and that layer should be at as high a level as is possible. This prevents lower levels (DAOs) from needing to make assumptions about the how they are being called - allowing them to be grouped into larger transactions in the future.

    Unless I have a good reason not to, I generally tend to use container managed transaction demarcation (CMT) and specify each session bean method as "Required".
  3. Where to put Transactions?[ Go to top ]

    As a rule of thumb, I would put all transaction demarcation at one layer, and that layer should be at as high a level as is possible.

    +1

    In case you have to use user-defined transactions, you should put this behavior in the entry point to each process, so that each process/service is contained in a single transaction.

    Regards,
    Martin
  4. Where to put Transactions?[ Go to top ]

    What are you using EJB for if not transaction management?

    The EJB which is your entry point from outside of the container (usually a SLSB using the session facade pattern) should manager you transaction whether explicity or automatically. DAOs should be passed connections and should not do any transaction control.