Handling Transactions

From: Scott McClure (scot..martblob.com)
Date: Wed Jul 21 2004 - 08:41:00 EDT

  • Next message: Mike Kienenberger: "Re: another toMany questions"

    In most Cayenne operations, you make the changes and then call commitChanges().
    In my application, this model is not working so well. In the Spring Hibernate
    code, there is a class that contains a callback in order to begin and end a
    session. Through this method, they have been very successful in creating more
    advanced features like declaritive transaction demarcation. The basic idea is
    to surround the request in a callback like this...

    API: DataContext.executeTransaction (Transaction)

    Code: dc.executeTransaction (new Transaction () {
             public Object execute () {
                //execute query, update some stuff...
                return results; //can be anything, a list, etc.
             }
          });

    Scott



    This archive was generated by hypermail 2.0.0 : Wed Jul 21 2004 - 08:41:03 EDT