public class JPA
extends java.lang.Object
Constructor and Description |
---|
JPA() |
Modifier and Type | Method and Description |
---|---|
static void |
bindForAsync(javax.persistence.EntityManager em)
Bind an EntityManager to the current HTTP context.
|
static void |
bindForSync(javax.persistence.EntityManager em)
Bind an EntityManager to the current HTTP context.
|
static JPAApi |
createFor(java.lang.String unitName)
Create a default JPAApi with name "default" and the given unit name.
|
static JPAApi |
createFor(java.lang.String name,
java.lang.String unitName)
Create a default JPAApi with the given persistence unit configuration.
|
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 JPAApi |
jpaApi()
Get the JPA api for the current play application.
|
static void |
withTransaction(java.lang.Runnable block)
Run a block of code in a JPA transaction.
|
static <T> T |
withTransaction(java.lang.String name,
boolean readOnly,
java.util.function.Supplier<T> block)
Run a block of code in a JPA transaction.
|
static <T> T |
withTransaction(java.util.function.Supplier<T> block)
Run a block of code in a JPA transaction.
|
static <T> F.Promise<T> |
withTransactionAsync(java.lang.String name,
boolean readOnly,
java.util.function.Supplier<F.Promise<T>> block)
Deprecated.
This may cause deadlocks
|
static <T> F.Promise<T> |
withTransactionAsync(java.util.function.Supplier<F.Promise<T>> block)
Deprecated.
This may cause deadlocks
|
public static JPAApi createFor(java.lang.String name, java.lang.String unitName)
public static JPAApi createFor(java.lang.String unitName)
public static JPAApi jpaApi()
public static javax.persistence.EntityManager em(java.lang.String key)
public static javax.persistence.EntityManager em()
public static void bindForSync(javax.persistence.EntityManager em)
public static void bindForAsync(javax.persistence.EntityManager em)
java.lang.RuntimeException
- if no HTTP context is present.public static <T> T withTransaction(java.util.function.Supplier<T> block)
block
- Block of code to execute.@Deprecated public static <T> F.Promise<T> withTransactionAsync(java.util.function.Supplier<F.Promise<T>> block)
block
- Block of code to execute.public static void withTransaction(java.lang.Runnable block)
block
- Block of code to execute.public static <T> T withTransaction(java.lang.String name, boolean readOnly, java.util.function.Supplier<T> block)
name
- The persistence unit namereadOnly
- Is the transaction read-only?block
- Block of code to execute.@Deprecated public static <T> F.Promise<T> withTransactionAsync(java.lang.String name, boolean readOnly, java.util.function.Supplier<F.Promise<T>> block)
name
- The persistence unit namereadOnly
- Is the transaction read-only?block
- Block of code to execute.