Discussions

EJB design: Q: how to use DTOs with Container Managed Transactions

  1. Hello all,

     what is your suggestion to use DTOs and still use container managed transactions?

    Any hints appreciated,
    Thomas Nagel
  2. DTO'S are just data holders. The standard pattern is to pass a dto to a a session bean which does an insert or update using data from the dto. Using cmt allows multiple session beans/dao's to be strung together in a single transaction
  3. Thanks, Kevin.
    Probably I need to be more specific.
    I'm working on a program the uses session beans as a facade, and DTOs to allow for bulk data transfer. So the question(s) could be more detailed:

    1. How do you control the transactions on the domain entities when using session beans as facade ?
    2. How do you keep transactions open etc. when using DTOs ? The entitiy bean objects may already be back in the pool, although the DTOs are in-use at the client. How do you synchronize the DTOs with the entity beans ? How do you open transactions for changing their data, or even delete the table rows ? etc. pp.

    Thanks,
    Thomas