public interface JPAApi
| Modifier and Type | Method and Description |
|---|---|
javax.persistence.EntityManager |
em(String name)
Get a newly created EntityManager for the specified persistence unit name.
|
void |
shutdown()
Close all entity manager factories.
|
JPAApi |
start()
Initialise JPA entity manager factories.
|
void |
withTransaction(Consumer<javax.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.
|
<T> T |
withTransaction(Function<javax.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.
|
void |
withTransaction(String name,
boolean readOnly,
Consumer<javax.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.
|
<T> T |
withTransaction(String name,
boolean readOnly,
Function<javax.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.
|
void |
withTransaction(String name,
Consumer<javax.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.
|
<T> T |
withTransaction(String name,
Function<javax.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.
|
JPAApi start()
javax.persistence.EntityManager em(String name)
name - The persistence unit name<T> T withTransaction(Function<javax.persistence.EntityManager,T> block)
T - type of resultblock - Block of code to executevoid withTransaction(Consumer<javax.persistence.EntityManager> block)
block - Block of code to execute<T> T withTransaction(String name, Function<javax.persistence.EntityManager,T> block)
T - type of resultname - The persistence unit nameblock - Block of code to executevoid withTransaction(String name, Consumer<javax.persistence.EntityManager> block)
name - The persistence unit nameblock - Block of code to execute<T> T withTransaction(String name, boolean readOnly, Function<javax.persistence.EntityManager,T> block)
T - type of resultname - The persistence unit namereadOnly - Is the transaction read-only?block - Block of code to executevoid withTransaction(String name, boolean readOnly, Consumer<javax.persistence.EntityManager> block)
name - The persistence unit namereadOnly - Is the transaction read-only?block - Block of code to executevoid shutdown()