4.4.3. The Persistence Interface
The infrastructure interface, serving as an entry point to data storage functionality.
The interface has the following methods:
-
createTransaction()
,getTransaction()
– obtain the interface to manage transactions. -
callInTransaction()
,runInTransaction()
- execute an action in a new transaction with or without return value. -
isInTransaction()
– checks if an active transaction exists at the moment. -
getEntityManager()
– returns the EntityManager instance bound to the current transaction. -
isSoftDeletion()
– allows you to determine if the soft deletion mode is active. -
setSoftDeletion()
– enables or disables the soft deletion mode. Setting this property affects all newly createdEntityManager
. instances. Soft deletion is enabled by default. -
getDbTypeConverter()
– returns the DbTypeConverter instance for the currently used database. -
getDataSource()
– returns thejavax.sql.DataSource
instance for the currently used database.WarningFor all
javax.sql.Connection
objects obtained throughgetDataSource().getConnection()
method theclose()
method should be called in thefinally
section after using the connection. Otherwise, the connection will not be returned to the pool. Over time, the pool will overflow and the application will not be able to execute database queries. -
getTools()
– returns an instance of thePersistenceTools
interface (see below).