Hi Michael, If you are adding this layer to wrap OJB, you may want to not throw an OJB specific exception from the method. I do a similar type of wrapper and throw a generic PersistenceException which is simply a wrapper for the OJB PersistenceBrokerException.
My .02 worth. Wally -----Original Message----- From: Michael Wiessler [mailto:[EMAIL PROTECTED] Sent: Saturday, July 12, 2003 5:10 PM To: OJB Mailing List Subject: your comments on my example save()-Method 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
