Package play.db.jpa
Class DefaultJPAApi
- Object
-
- play.db.jpa.DefaultJPAApi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultJPAApi.JPAApiProvider
-
Constructor Summary
Constructors Constructor Description DefaultJPAApi(JPAConfig jpaConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.persistence.EntityManagerem(String name)Get a newly created EntityManager for the specified persistence unit name.voidshutdown()Close all entity manager factories.JPAApistart()Initialise JPA entity manager factories.voidwithTransaction(String name, boolean readOnly, Consumer<jakarta.persistence.EntityManager> block)Run a block of code with a newly created EntityManager for the named Persistence Unit.<T> TwithTransaction(String name, boolean readOnly, Function<jakarta.persistence.EntityManager,T> block)Run a block of code with a newly created EntityManager for the named Persistence Unit.voidwithTransaction(String name, Consumer<jakarta.persistence.EntityManager> block)Run a block of code with a newly created EntityManager for the named Persistence Unit.<T> TwithTransaction(String name, Function<jakarta.persistence.EntityManager,T> block)Run a block of code with a newly created EntityManager for the named Persistence Unit.voidwithTransaction(Consumer<jakarta.persistence.EntityManager> block)Run a block of code with a newly created EntityManager for the default Persistence Unit.<T> TwithTransaction(Function<jakarta.persistence.EntityManager,T> block)Run a block of code with a newly created EntityManager for the default Persistence Unit.
-
-
-
Constructor Detail
-
DefaultJPAApi
public DefaultJPAApi(JPAConfig jpaConfig)
-
-
Method Detail
-
start
public JPAApi start()
Initialise JPA entity manager factories.
-
em
public jakarta.persistence.EntityManager em(String name)
Get a newly created EntityManager for the specified persistence unit name.
-
withTransaction
public <T> T withTransaction(Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.- Specified by:
withTransactionin interfaceJPAApi- Type Parameters:
T- type of result- Parameters:
block- Block of code to execute- Returns:
- code execution result
-
withTransaction
public void withTransaction(Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the default Persistence Unit.- Specified by:
withTransactionin interfaceJPAApi- Parameters:
block- Block of code to execute
-
withTransaction
public <T> T withTransaction(String name, Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Specified by:
withTransactionin interfaceJPAApi- Type Parameters:
T- type of result- Parameters:
name- The persistence unit nameblock- Block of code to execute- Returns:
- code execution result
-
withTransaction
public void withTransaction(String name, Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Specified by:
withTransactionin interfaceJPAApi- Parameters:
name- The persistence unit nameblock- Block of code to execute
-
withTransaction
public <T> T withTransaction(String name, boolean readOnly, Function<jakarta.persistence.EntityManager,T> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Specified by:
withTransactionin interfaceJPAApi- 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
public void withTransaction(String name, boolean readOnly, Consumer<jakarta.persistence.EntityManager> block)
Run a block of code with a newly created EntityManager for the named Persistence Unit.- Specified by:
withTransactionin interfaceJPAApi- Parameters:
name- The persistence unit namereadOnly- Is the transaction read-only?block- Block of code to execute
-
-