Adempiere 3.5.2a

org.compiere.util
Class Trx

java.lang.Object
  extended by org.compiere.util.Trx
All Implemented Interfaces:
VetoableChangeListener, EventListener

public class Trx
extends Object
implements VetoableChangeListener

Transaction Management. - Create new Transaction by Trx.get(name); - ..transactions.. - commit(); ---- start(); ---- commit(); - close();

Version:
$Id$
Author:
Jorg Janke, Low Heng Sin - added rollback(boolean) and commit(boolean) [20070105] - remove unnecessary use of savepoint - use UUID for safer transaction name generation

Method Summary
 boolean close()
          End Transaction and Close Connection
 boolean commit()
          Commit
 boolean commit(boolean throwException)
          Commit
static String createTrxName()
          Create unique Transaction Name
static String createTrxName(String prefix)
          Create unique Transaction Name
static Trx get(String trxName, boolean createNew)
          Get Transaction
static Trx[] getActiveTransactions()
           
 Connection getConnection()
          Get Connection
 Date getStartTime()
           
 String getTrxName()
          Get Name
 boolean isActive()
          Transaction is Active
 boolean rollback()
          Rollback
 boolean rollback(boolean throwException)
          Rollback
 boolean rollback(Savepoint savepoint)
          Rollback
 Savepoint setSavepoint(String name)
           
 boolean start()
          Start Trx
 String toString()
          String Representation
 void vetoableChange(PropertyChangeEvent evt)
          Vetoable Change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public static Trx get(String trxName,
                      boolean createNew)
Get Transaction

Parameters:
trxName - trx name
createNew - if false, null is returned if not found
Returns:
Transaction or null

createTrxName

public static String createTrxName(String prefix)
Create unique Transaction Name

Parameters:
prefix - optional prefix
Returns:
unique name

createTrxName

public static String createTrxName()
Create unique Transaction Name

Returns:
unique name

getConnection

public Connection getConnection()
Get Connection

Returns:
connection

getTrxName

public String getTrxName()
Get Name

Returns:
name

start

public boolean start()
Start Trx

Returns:
true if trx started

getStartTime

public Date getStartTime()
Returns:
The start time of this transaction

isActive

public boolean isActive()
Transaction is Active

Returns:
true if transaction active

rollback

public boolean rollback(boolean throwException)
                 throws SQLException
Rollback

Parameters:
throwException - if true, re-throws exception
Returns:
true if success, false if failed or transaction already rollback
Throws:
SQLException

rollback

public boolean rollback()
Rollback

Returns:
true if success, false if failed or transaction already rollback

rollback

public boolean rollback(Savepoint savepoint)
                 throws SQLException
Rollback

Parameters:
throwException - if true, re-throws exception
Returns:
true if success, false if failed or transaction already rollback
Throws:
SQLException

commit

public boolean commit(boolean throwException)
               throws SQLException
Commit

Parameters:
throwException - if true, re-throws exception
Returns:
true if success
Throws:
SQLException

commit

public boolean commit()
Commit

Returns:
true if success

close

public boolean close()
End Transaction and Close Connection

Returns:
true if success

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Parameters:
name -
Returns:
Savepoint
Throws:
SQLException

toString

public String toString()
String Representation

Overrides:
toString in class Object
Returns:
info

vetoableChange

public void vetoableChange(PropertyChangeEvent evt)
                    throws PropertyVetoException
Vetoable Change. Called from CCache to close connections

Specified by:
vetoableChange in interface VetoableChangeListener
Parameters:
evt - event
Throws:
PropertyVetoException

getActiveTransactions

public static Trx[] getActiveTransactions()
Returns:
Trx[]

Adempiere 3.5.2a

Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.