Hi there,

here is my proposal for an example save()-Method, using the
PersistenceBroker-API,
working with any oject.
I've put it in a class called BasicORMapper.
It seems to work quite stable.

I've implemented a delte() and several load()-Methods similar to this
save()-Method.
All methods are static.

What do you thik about this implementation ?
Would you do it in another way ?
Have I overseen any pitfalls ?

thank you for your feedback

Michael


following : the code ;)

----------------------------------------------------------------------------
--------------

public static void save(Object object) throws PersistenceBrokerException
{
        // Get a broker from the Pool
        PersistenceBroker pbroker =
PersistenceBrokerFactory.defaultPersistenceBroker();
        if (pbroker.isInTransaction())  // Just to be sure ;)
        {
                pbroker.abortTransaction();
        }
        pbroker.beginTransaction();             // Starting the transaction
        try
        {
                pbroker.store(object);              // store the object
            try
            {
                pbroker.commitTransaction();    // committing the
transaction
            }
            catch (TransactionAbortedException taex)        // if not able
to commit
            {
                pbroker.abortTransaction();     // Start a roll-back
                pbroker.close();                // close the broker - return
it to connection-pool
                throw new PersistenceBrokerException();
                }
        }
        catch (PersistenceBrokerException e)    // If not able to store
        {
                pbroker.close();                // close the broker - return it to
connection-pool
            throw new PersistenceBrokerException();
      }
      pbroker.close();                // close the broker - return it to
connection-pool
}


----------------------------------------------------------------------------
--------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to