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 created EntityManager. instances. Soft deletion is enabled by default.

  • getDbTypeConverter() – returns the DbTypeConverter instance for the currently used database.

  • getDataSource() – returns the javax.sql.DataSource instance for the currently used database.


    For all javax.sql.Connection objects obtained through getDataSource().getConnection() method the close() method should be called in the finally 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 the PersistenceTools interface (see below).