Controlling transactions of two persistence frameworks


General J2EE: Controlling transactions of two persistence frameworks

  1. Hi.
    We have a code base which currently is using two different persistence framworks. Sometimes there is a situation where we have client code(client of the business code) that needs to persist data in both persistence framworks at the same time, in the same transaction ! We do currently have some trouble achieving this(sometimes the first persistence framework commits but the second fails) and we are going to rewrite transaction managment. Could anybody perhaps give any tips, hints, articles, patterns etc. that dicuss this problem and how to create a proper architecture.
  2. My preference is to use CMT for transaction control. That way you need not get bogged down in the transaction management peculiarities of individual persistence frameworks.

    In other words, the persistence framework does not know or care about transactions. In iBatis for example, you delegate control to an unspecified higher level in the xml config file:

      <transactionManager type="EXTERNAL">

    At runtime, that higher level is an EJB with CMT defined.