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 interface
The jdbc task interface. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet theQuery
instance for the given model class.protected jakarta.persistence.EntityManager
Get the instance of currentEntityManager
.protected void
inTransaction
(Runnable task) Run the given task inside a transaction that is committed after the task is completed.protected void
jdbcTask
(JpaSupport.JDBCTask task) Perform JDBC related task using theConnection
managed by the currentEntityManager
.
-
Constructor Details
-
JpaSupport
public JpaSupport()
-
-
Method Details
-
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager()Get the instance of currentEntityManager
.- Returns:
- the
EntityManager
instance
-
all
Get theQuery
instance 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 theConnection
managed by the currentEntityManager
.- Parameters:
task
- The task to be performed- Throws:
jakarta.persistence.PersistenceException
- Generally indicates wrappedSQLException
-