T callWithConnection(
ConnectionFunction<C,T> function
)
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< C >- the connection type, usually {@code java.sql.Connection}< T >- the type of result returned by the function
- Return:
- the value returned by {@link ConnectionFunction#apply} .
- Throws:
- PersistenceException - wrapping the checked {@link Exception} thrown by {@link ConnectionFunction#apply} , if any
- Since:
- JPA 3.2