@ApplicationScoped public class TransactionHelper extends Object
Attention: please be aware that this helper only works for @Transactional with auto-detecting the EntityManager! If you need to manually specify the EntityManager Qualifier for another EntityManager, then you need to copy this code and adopt it.
Usage:
SomeEntity retVal = TransactionHelper.getInstance().executeTransactional( new Callable() { private @Inject EntityManager em; public SomeEntity call() throws Exception { return em.find(entityId, SomeEntity.class); } } );
Constructor and Description |
---|
TransactionHelper() |
Modifier and Type | Method and Description |
---|---|
<T> T |
executeTransactional(java.util.concurrent.Callable<T> callable)
Execute the given
Callable in a Transitional manner. |
static TransactionHelper |
getInstance() |
public static TransactionHelper getInstance()
@Transactional public <T> T executeTransactional(java.util.concurrent.Callable<T> callable) throws Exception
Callable
in a Transitional manner.Copyright © 2015 The Apache Software Foundation. All rights reserved.