> Hello all
>
> Does the Peer OM have any transaction support now? I searched the archive
> and the last message about this was last May. I see that peers have update
> methods which can be passed an external dbconnection.
>
> I'm assuming it should be used like this:
Take a look at BasePeer's beginTransaction(), commitTransaction and
rollbackTransaction().
> public static void doMyTransaction()
> throws Exception
> {
> DBConnection db = null;
> try
> {
> // get a connection to the db
> db = DBBroker.getInstance().getConnection();
> Connection connection = db.getConnection();
>
> // Turn autocommit off. I'm assuming the peer methods that
allow
> a connection to be passed
> // don't do this already.
> connection.setAutoCommit(false);
>
> // Create some criteria.....
> // Use the criteria in some way:
> myPeer.doUpdate(criteria, connection);
> myPeer2.doInsert(criteria2, connection);
> myPeer3.doDelete(criteria3, connection);
>
> // If all goes well, commit the changes
> connection.commit();
> }
> catch(Exception e)
> {
> // If problems occur - rollback
> connection.rollback();
> }
> finally
> {
> DBBroker.getInstance().releaseConnection(db);
> }
> }
>
> Q?
>
> 1. Does using the DBBroker in this way provide a connection that uses the
> properties from the props file?
Yes
> 2. Does the connection come from the pool? I don't want to create a new
> stand-alone connection for obvious reasons.
It comes from the Pool
> The following comment above all methods that have a connection parameter,
> confuses me:
The doSelect(Criteria) method without a connection parameter will get a new
connection and do the database action. You don't need to do anything
special for connections. Otherwise you need to pass a connection parameter.
If you send a patch with a less confusing comment I'll commit it :-)
> /*
>
> This method is to be used during a transaction,
> otherwise use the doSelect(Criteria) method. It will take care of
> the connection details internally.
>
> */
>
> What connection details will it take care of
> Hope that this is all clear.
>
> Gareth
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]