Re: Integration with Session Beans

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Nov 14 2002 - 13:36:06 EST

  • Next message: Andrus: "Re: Why must generate AUTO_PK_SUPPORT table ?"

    Hi David,

     

    >> So, all we need in Cayenne is to configure DataNode class to avoid
    >> explicit
    >> commit to the database after it performs a set of insert/update/delete
    >> queries. If this line of thinking is right, I can make a patch to
    > Cayenne
    >> to behave exactly this way when asked. So within a SessionBean you
    > would
    >> call DataContext.commit() that would write the changes to the database
    >> without committing, hoping that container will do this somewhere
    >> downstream.
    >>
    > It is exactly what I need. What happen to Cayenne data objects if the
    > container couldn't commit the transaction? Do Cayenne data objects undo
    > changes or how to undo changes?

    Just like EOF, when an exception happens on commit, the object state in
    DataContext doesn't change. All modified objects are still in a "dirty"
    state in the DataContext. If the desired behavior is to "forget" the
    changes, so that bean can be serving the next request, the best bet is to
    start with a fresh DataContext on every request. This should work esp. well
    with stateless beans.

    >
    >> Another possibility to fine tune the behavior is to use hooks in
    >> SessionSynchronization interface. And this may work even without
    > changes
    >> to
    >> Cayenne. Basically you would commit DataContext in "beforeCompletion"
    >> method, and if it throws, the whole transaction is rolled back.
    >>
    > I'm afraid it isn't clear. My main concern is: Could a Stateless Session
    > Bean implement the SessionSynchronization interface?
    >
    > Because of clustering, I would like to avoid Stateful Session Beans.

    Since I don't really use EJB, I don't remember the details about
    SessionSynchronization. Well, if it only works for stateful beans, then
    forget it.

    As for the patch that I mentioned (to avoid commits) it should be pretty
    trivial. So let me know if you decide to go with Cayenne, then we can
    discuss the concrete steps to make this change.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Nov 14 2002 - 13:36:12 EST