Package com.axelor.db
Class JpaSupport
java.lang.Object
com.axelor.db.JpaSupport
- Direct Known Subclasses:
MailController,ResponseInterceptor,TaskController
This class provides some useful methods in JPA context, can be used as a base class for services
to make it more convenient.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceThe jdbc task interface. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet theQueryinstance for the given model class.protected jakarta.persistence.EntityManagerGet the instance of currentEntityManager.protected voidinTransaction(Runnable task) Run the given task inside a transaction that is committed after the task is completed.protected voidjdbcTask(JpaSupport.JDBCTask task) Perform JDBC related task using theConnectionmanaged by the currentEntityManager.
-
Constructor Details
-
JpaSupport
public JpaSupport()
-
-
Method Details
-
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager()Get the instance of currentEntityManager.- Returns:
- the
EntityManagerinstance
-
all
Get theQueryinstance for the given model class.- Type Parameters:
T- the type of the model- Parameters:
modelClass- the model class- Returns:
- an instance of
Query
-
inTransaction
Run the given task inside a transaction that is committed after the task is completed.- Parameters:
task- the task to run
-
jdbcTask
Perform JDBC related task using theConnectionmanaged by the currentEntityManager.- Parameters:
task- The task to be performed- Throws:
jakarta.persistence.PersistenceException- Generally indicates wrappedSQLException
-