org.silverpeas.persistence
Class Transaction

java.lang.Object
  extended by org.silverpeas.persistence.Transaction

@Service
public class Transaction
extends Object

A transaction. All processes it performs will be in charge by the JPA transaction manager.

Author:
mmoquillon

Nested Class Summary
static interface Transaction.Process<RETURN_VALUE>
          Defines a process to execute.
 
Constructor Summary
Transaction()
           
 
Method Summary
static Transaction getTransaction()
          Gets a transaction instance in order to perform some tasks transactionally.
<RETURN_VALUE>
RETURN_VALUE
perform(Transaction.Process<RETURN_VALUE> process)
          The given process is executed in a transaction : support a current transaction, create a new one if none exists.
static
<RETURN_VALUE>
RETURN_VALUE
performInOne(Transaction.Process<RETURN_VALUE> process)
          Performs in a single transaction the specified process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transaction

public Transaction()
Method Detail

getTransaction

public static Transaction getTransaction()
Gets a transaction instance in order to perform some tasks transactionally.

Returns:
a transaction.

performInOne

public static <RETURN_VALUE> RETURN_VALUE performInOne(Transaction.Process<RETURN_VALUE> process)
Performs in a single transaction the specified process.

Type Parameters:
RETURN_VALUE - the type of the return value.
Parameters:
process - the process to execute in a transaction.
Returns:
the result of the process.

perform

@Transactional
public <RETURN_VALUE> RETURN_VALUE perform(Transaction.Process<RETURN_VALUE> process)
The given process is executed in a transaction : support a current transaction, create a new one if none exists. Analogous to EJB transaction attribute of the same name.

Type Parameters:
RETURN_VALUE - the type of the return value.
Parameters:
process - the process to execute in a transaction.
Returns:
the result of the process.


Copyright © 2016 Silverpeas. All Rights Reserved.