PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
    tx.begin(); // Start the PM transaction
    ... perform some persistence operations
    tx.commit(); // Commit the PM transaction
}
finally
{
    if (tx.isActive())
    {
        tx.rollback(); // Error occurred so rollback the PM transaction
    }
}