org.apache.myfaces.extensions.cdi.jpa.api
Class TransactionHelper

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.jpa.api.TransactionHelper

@ApplicationScoped
public class TransactionHelper
extends Object

This class allows to execute CDI-unmanaged code blocks in a @Transactional manner. This is handy if you like e.g. to execute database code in a unit test tearDown method.

Attention: please be aware that this helper only works for @Transactional with the default qualifier! If you need the functionality for another EntityManager, then you need to copy this code and adopt it

Usage:


 
>


Constructor Summary
TransactionHelper()
           
 
Method Summary
<T> T
executeTransactional(Callable<T> callable)
          Execute the given Callable in a Transitional manner.
static TransactionHelper getInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionHelper

public TransactionHelper()
Method Detail

getInstance

public static TransactionHelper getInstance()

executeTransactional

@Transactional
public <T> T executeTransactional(Callable<T> callable)
                       throws Exception
Execute the given Callable in a Transitional manner.

Type Parameters:
T - the return type of the executed Callable
Parameters:
callable -
Returns:
the return value of the executed Callable
Throws:
Exception


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.