Consider making BatchStatement and BoundStatement immutable

Description

These statements are typically used in a "mutable-like" fashion:

  • bound statement: create an instance, then set the variables

  • batch statement: create an instance, then add the children

Currently the implementations are actually mutable, and therefore not thread-safe – and error-prone if you reuse them for async executions. It was done this way to avoid the cost of creating intermediary objects, but maybe we're overestimating that cost.

Benchmark the overhead of purely immutable approaches:

  1. have each mutating method create a new instance

  2. alternatively, use a builder like SimpleStatement. This has the advantage of only creating one intermediary object. On the other hand, this might be less convenient for custom implementations, because each needs its own builder (instead of having the whole contract captured in a single interface).

If we go with solution 1, we might want to use it for SimpleStatement too, for the sake of uniformity.

Environment

None

Pull Requests

None

Activity

Show:
Olivier Michallat
July 19, 2017, 10:17 PM

Also add a method to bind all the values in a bound statement in one go, like bind(Object...) in 3.x.

Fixed

Assignee

Olivier Michallat

Reporter

Olivier Michallat

Labels

None

PM Priority

None

Affects versions

None

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Priority

Major
Configure