3.4.3. The Persistence Interface
Persistence interface is designed to be an entry point to the data storage functionality provided by the ORM layer.
The interface has the following methods:
runInTransaction()- execute an action in a new transaction with or without return value. The methods can accept a data store name. If it is not provided, the main data store is assumed.
isInTransaction()– checks if there is an active transaction the moment.
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
EntityManagerinstances. Soft deletion is enabled by default.
getDbTypeConverter()– returns the DbTypeConverter instance for the main database or for an additional data store.
getDataSource()– returns the
javax.sql.DataSourceinstance for the main database or for an additional data store.
javax.sql.Connectionobjects obtained through
close()method should be called in the
finallysection 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
PersistenceToolsinterface (see below).