public class JPA
extends java.lang.Object
Constructor and Description |
---|
JPA() |
Modifier and Type | Method and Description |
---|---|
static void |
bindForCurrentThread(javax.persistence.EntityManager em)
Bind an EntityManager to the current thread.
|
static javax.persistence.EntityManager |
em()
Get the default EntityManager for this thread.
|
static javax.persistence.EntityManager |
em(java.lang.String key)
Get the EntityManager for specified persistence unit for this thread.
|
static void |
withTransaction(F.Callback0 block)
Run a block of code in a JPA transaction.
|
static <T> T |
withTransaction(F.Function0<T> block)
Run a block of code in a JPA transaction.
|
static <T> T |
withTransaction(java.lang.String name,
boolean readOnly,
F.Function0<T> block)
Run a block of code in a JPA transaction.
|
static <T> F.Promise<T> |
withTransactionAsync(F.Function0<F.Promise<T>> block)
Run a block of asynchronous code in a JPA transaction.
|
static <T> F.Promise<T> |
withTransactionAsync(java.lang.String name,
boolean readOnly,
F.Function0<F.Promise<T>> block)
Run a block of asynchronous code in a JPA transaction.
|
public static javax.persistence.EntityManager em(java.lang.String key)
public static javax.persistence.EntityManager em()
public static void bindForCurrentThread(javax.persistence.EntityManager em)
public static <T> T withTransaction(F.Function0<T> block) throws java.lang.Throwable
block
- Block of code to execute.java.lang.Throwable
public static <T> F.Promise<T> withTransactionAsync(F.Function0<F.Promise<T>> block) throws java.lang.Throwable
block
- Block of code to execute.java.lang.Throwable
public static void withTransaction(F.Callback0 block)
block
- Block of code to execute.public static <T> T withTransaction(java.lang.String name, boolean readOnly, F.Function0<T> block) throws java.lang.Throwable
name
- The persistence unit namereadOnly
- Is the transaction read-only?block
- Block of code to execute.java.lang.Throwable
public static <T> F.Promise<T> withTransactionAsync(java.lang.String name, boolean readOnly, F.Function0<F.Promise<T>> block) throws java.lang.Throwable
name
- The persistence unit namereadOnly
- Is the transaction read-only?block
- Block of code to execute.java.lang.Throwable