EJB & Cayenne transactional behavior

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Apr 27 2002 - 16:00:55 EDT

  • Next message: Johnny Ren: "Re: EJB & Cayenne transactional behavior"

    Hi EJB gurus on this list,

    we are taking some steps to integrate Cayenne with EJB. There are some
    design issues I wanted to discuss.

    Topic I am talking about here is (long and boring ;-)):

    "Transactional behavior of Cayenne when used for data persistence in
    Stateful Session Beans".

    Standalone Cayenne would wrap DataContext.commitChanges in a database
    transaction. For an EJB application this doesn't seem like a good
    solution, since transaction management should be declarative and managed
    by the container. Furthermore there are 3 types of EJB transaction
    attributes:

    1. No outside transactional context: "Never" or "Not Supported"
    2. Has outside transactional context: "Required", "Mandatory", "RequiresNew"
    3. May or may not have outside context: "Supports"

    Here is the suggested solution to the both of them, and after that
    questions that I have.

    1. Requires no changes to Cayenne. DataContext.commitChanges needs to be
    called explicitly from the bean java code

    2. Requires hooks to a bean via SessionSynchronization interface.
    "DataContext.commitChanges" will NOT commit transactions to the database
    (and normally shouldn't be called explicitly anyways). Changes will be
    saved to the database in "SessionSynchronization.beforeCommit"

    Questions:

    - Do you see any flaws in this logic? Or maybe someone has better ideas?

    - in "SessionSynchronization.beforeCommit" Cayenne should write changes
    to the database, but shouldn't attempt to commit explicitly, leaving
    this to the EJB server. Is this correct?

    -- 
    ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
    - Andrei (a.k.a. Andrus) Adamchik
    http://objectstyle.org
    email: andrus at objectstyle dot org
    



    This archive was generated by hypermail 2.0.0 : Sat Apr 27 2002 - 16:01:02 EDT