Package play.db.jpa
Interface JPAApi
-
- All Known Implementing Classes:
DefaultJPAApi
public interface JPAApi
JPA API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description jakarta.persistence.EntityManager
em(java.lang.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(java.lang.String name, boolean readOnly, java.util.function.Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.<T> T
withTransaction(java.lang.String name, boolean readOnly, java.util.function.Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.void
withTransaction(java.lang.String name, java.util.function.Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.<T> T
withTransaction(java.lang.String name, java.util.function.Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.void
withTransaction(java.util.function.Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.<T> T
withTransaction(java.util.function.Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.
-
-
-
Method Detail
-
start
JPAApi start()
Initialise JPA entity manager factories.- Returns:
- JPAApi instance
-
em
jakarta.persistence.EntityManager em(java.lang.String name)
Get a newly created EntityManager for the specified persistence unit name.- Parameters:
name
- The persistence unit name- Returns:
- EntityManager for the specified persistence unit name
-
withTransaction
<T> T withTransaction(java.util.function.Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.- Type Parameters:
T
- type of result- Parameters:
block
- Block of code to execute- Returns:
- code execution result
-
withTransaction
void withTransaction(java.util.function.Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.- Parameters:
block
- Block of code to execute
-
withTransaction
<T> T withTransaction(java.lang.String name, java.util.function.Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Type Parameters:
T
- type of result- Parameters:
name
- The persistence unit nameblock
- Block of code to execute- Returns:
- code execution result
-
withTransaction
void withTransaction(java.lang.String name, java.util.function.Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Parameters:
name
- The persistence unit nameblock
- Block of code to execute
-
withTransaction
<T> T withTransaction(java.lang.String name, boolean readOnly, java.util.function.Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Type Parameters:
T
- type of result- Parameters:
name
- The persistence unit namereadOnly
- Is the transaction read-only?block
- Block of code to execute- Returns:
- code execution result
-
withTransaction
void withTransaction(java.lang.String name, boolean readOnly, java.util.function.Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Parameters:
name
- The persistence unit namereadOnly
- Is the transaction read-only?block
- Block of code to execute
-
shutdown
void shutdown()
Close all entity manager factories.
-
-