Top Description Methods
org.springframework.r2dbc.core

public Interface ConnectionAccessor

Known Direct Subinterfaces
org.springframework.r2dbc.core.DatabaseClient
Imports
java.util.function.Function, io.r2dbc.spi.Connection, reactor.core.publisher.Flux, .Mono

Interface declaring methods that accept callback Function to operate within the scope of a Connection. Callback functions operate on a provided connection and must not close the connection as the connections may be pooled or be subject to other kinds of resource management.

Callback functions are responsible for creating a org.reactivestreams.Publisher that defines the scope of how long the allocated Connection is valid. Connections are released after the publisher terminates.

This serves as a base interface for DatabaseClient.

Author
Mark Paluch
Since
5.3
See Also
DatabaseClient

Method Summary

Modifier and TypeMethod and Description
public <T> Mono<T>

Returns:

the resulting Mono
inConnection
(Function<Connection, Mono<T>>
the callback object that specifies the connection action
action
)

Execute a callback Function within a Connection scope.

public <T> Flux<T>

Returns:

the resulting Flux
inConnectionMany
(Function<Connection, Flux<T>>
the callback object that specifies the connection action
action
)

Execute a callback Function within a Connection scope.

Method Detail

inConnectionback to summary
public <T> Mono<T> inConnection(Function<Connection, Mono<T>> action)

Execute a callback Function within a Connection scope. The function is responsible for creating a Mono. The connection is released after the Mono terminates (or the subscription is cancelled). Connection resources must not be passed outside the Function closure, otherwise resources may get defunct.

Parameters
action:Function<Connection, Mono<T>>

the callback object that specifies the connection action

Returns:Mono<T>

the resulting Mono

Exceptions
DataAccessException:
in case of any errors
inConnectionManyback to summary
public <T> Flux<T> inConnectionMany(Function<Connection, Flux<T>> action)

Execute a callback Function within a Connection scope. The function is responsible for creating a Flux. The connection is released after the Flux terminates (or the subscription is cancelled). Connection resources must not be passed outside the Function closure, otherwise resources may get defunct.

Parameters
action:Function<Connection, Flux<T>>

the callback object that specifies the connection action

Returns:Flux<T>

the resulting Flux

Exceptions
DataAccessException:
in case of any errors