Re: Integration with Session Beans

From: Andrus (andru..bjectstyle.org)
Date: Thu Nov 14 2002 - 00:09:34 EST

  • Next message: Andrus: "Re: Could you tell me how to use the InsertQuery class to insert recorde into database.Anxious!"

    Hi David,

    in the situation you described (no data objects transferred to the client)
    using Cayenne seems to be absolutely reasonable. See my comments below on
    the details.

    At 04:20 PM 11/13/2002 -0600, David Solis wrote:
    >Hi Andrus,
    >I'm sorry I'm afraid my question wasn't specific.
    >
    >We developed a system based on a middleware and several presentation
    >tiers (html, wap and web services). The middleware is based on services
    >instead of data. We have several Session Beans to provide services to
    >the presentation tier and each service could use Entity Beans to
    >persistence.
    >Because of development time, I want to use Cayenne instead of Entity
    >Beans.

    So, you still have an RDBMS somewhere to save data, right?

    >I'm thinking in a Session Bean (stateless but could be stateful) as the
    >façade to Cayenne data objects. I don't want to expose these data
    >objects to the presentation tier. My main requirement is DataContext
    >implements java.io.Serializable (already does) and my main question is
    >how to manage transactions between Cayenne and a Session Bean?
    >I'm newbie to Cayenne but I know very well Apple's EOF.

    EOF experience should be very helpful in conceptualizing stuff, though we
    implement things differently...

    Anyway, correct me if I am wrong here... If any uncommitted database
    changes are written via a java.sql.Connection, EJB container must commit
    them when the time comes, right? Is this what declarative transactions are
    about?

    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.

    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.

    What do you think?

    Also I am really interested in how this goes, so keep this list posted on
    your progress.

    ;-)

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Nov 14 2002 - 00:08:59 EST