void runWithConnection(
ConnectionConsumer<C> action
)
Execute the given action 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 action is executed in the context of the transaction. The given action 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:
action- the action< C >- the connection type, usually {@code java.sql.Connection}
- Throws:
- PersistenceException - wrapping the checked {@link Exception} thrown by {@link ConnectionConsumer#accept} , if any
- Since:
- JPA 3.2