Jakarta Persistence (JPA) Method
T callWithConnection(
ConnectionFunction<C,T> function
)
- Type Parameters:
<T>- the type of result returned by the function<C>- the connection type, usuallyjava.sql.Connection
Call the given function and return its result using the database connection underlying this
EntityManager. Usually, the connection is a JDBC connection, but a provider might support some other native connection type, and is not required to support java.sql.Connection. If this EntityManager is associated with a transaction, the function is executed in the context of the transaction. The given function should close any resources it creates, but should not close the connection itself, nor commit or roll back the transaction. If the given action throws an exception, the persistence provider must mark the transaction for rollback.- Parameters:
function- the function
- Returns:
- the value returned by
ConnectionFunction.apply..
- Throws:
- wrapping the checkedPersistenceExceptionExceptionthrown byConnectionFunction.apply, if any.
- Since:
- Jakarta Persistence (JPA) 3.2