| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultJPAApi.JPAApiProvider |
| Constructor and Description |
|---|
DefaultJPAApi(JPAConfig jpaConfig,
JPAEntityManagerContext entityManagerContext) |
| Modifier and Type | Method and Description |
|---|---|
javax.persistence.EntityManager |
em()
Get the EntityManager for a particular persistence unit for this thread.
|
javax.persistence.EntityManager |
em(String name)
Get the EntityManager for the specified persistence unit name.
|
void |
shutdown()
Close all entity manager factories.
|
JPAApi |
start()
Initialise JPA entity manager factories.
|
<T> T |
withTransaction(Function<javax.persistence.EntityManager,T> block)
Run a block of code with the EntityManager for the named Persistence Unit.
|
void |
withTransaction(Runnable block)
Run a block of code in a JPA transaction.
|
<T> T |
withTransaction(String name,
boolean readOnly,
Function<javax.persistence.EntityManager,T> block)
Run a block of code with the EntityManager for the named Persistence Unit.
|
<T> T |
withTransaction(String name,
boolean readOnly,
Supplier<T> block)
Run a block of code in a JPA transaction.
|
<T> T |
withTransaction(String name,
Function<javax.persistence.EntityManager,T> block)
Run a block of code with the EntityManager for the named Persistence Unit.
|
<T> T |
withTransaction(Supplier<T> block)
Run a block of code in a JPA transaction.
|
public DefaultJPAApi(JPAConfig jpaConfig, JPAEntityManagerContext entityManagerContext)
public JPAApi start()
public javax.persistence.EntityManager em(String name)
public javax.persistence.EntityManager em()
public <T> T withTransaction(Function<javax.persistence.EntityManager,T> block)
withTransaction in interface JPAApiT - type of resultblock - Block of code to executepublic <T> T withTransaction(String name, Function<javax.persistence.EntityManager,T> block)
withTransaction in interface JPAApiT - type of resultname - The persistence unit nameblock - Block of code to executepublic <T> T withTransaction(String name, boolean readOnly, Function<javax.persistence.EntityManager,T> block)
withTransaction in interface JPAApiT - type of resultname - The persistence unit namereadOnly - Is the transaction read-only?block - Block of code to executepublic <T> T withTransaction(Supplier<T> block)
withTransaction in interface JPAApiT - type of resultblock - Block of code to executepublic void withTransaction(Runnable block)
withTransaction in interface JPAApiblock - Block of code to executepublic <T> T withTransaction(String name, boolean readOnly, Supplier<T> block)
withTransaction in interface JPAApiT - type of resultname - The persistence unit namereadOnly - Is the transaction read-only?block - Block of code to execute