Record Class CommitStrategy
java.lang.Object
java.lang.Record
io.bloviate.db.CommitStrategy
- Record Components:
mode- the commit modebatches- the batch cadence forCommitStrategy.Mode.EVERY_N_BATCHES(ignored otherwise)
How a
TableFiller commits the rows it inserts.
By default (connectionDefault()) the fill engine does not touch the connection's
transaction state at all — it relies on whatever autocommit the caller's connection has, which for
a typical autocommit connection means a commit per executeBatch(). Disabling autocommit and
committing less often cuts commit overhead and is usually faster.
connectionDefault()— the engine leaves autocommit alone (back-compatible default).perTable()— autocommit off, a single commit once the table is fully filled.everyNBatches(int)— autocommit off, commit after everynJDBC batches (and once more for the trailing partial batch), bounding the size of an open transaction.
For anything other than connectionDefault() the engine sets autocommit off for the fill,
rolls back on error, and restores the connection's prior autocommit setting when done.
- Since:
- 2.10.0
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCommitStrategy(CommitStrategy.Mode mode, int batches) Validates the mode/batches pairing. -
Method Summary
Modifier and TypeMethodDescriptionintbatches()Returns the value of thebatchesrecord component.static CommitStrategyThe back-compatible default: the engine never changes the connection's autocommit state.final booleanIndicates whether some other object is "equal to" this one.static CommitStrategyeveryNBatches(int n) Autocommit off, commit after everynJDBC batches.final inthashCode()Returns a hash code value for this object.booleanWhether the engine manages the transaction (i.e. anything other thanCommitStrategy.Mode.CONNECTION_DEFAULT).mode()Returns the value of themoderecord component.static CommitStrategyperTable()Autocommit off, a single commit once the table is fully filled.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CommitStrategy
Validates the mode/batches pairing.- Throws:
IllegalArgumentException- ifmodeis null, orbatches < 1forCommitStrategy.Mode.EVERY_N_BATCHES
-
-
Method Details
-
connectionDefault
The back-compatible default: the engine never changes the connection's autocommit state.- Returns:
- a
CommitStrategy.Mode.CONNECTION_DEFAULTstrategy
-
perTable
Autocommit off, a single commit once the table is fully filled.- Returns:
- a
CommitStrategy.Mode.PER_TABLEstrategy
-
everyNBatches
Autocommit off, commit after everynJDBC batches.- Parameters:
n- the number of batches between commits; must be>= 1- Returns:
- the strategy
-
managesTransaction
public boolean managesTransaction()Whether the engine manages the transaction (i.e. anything other thanCommitStrategy.Mode.CONNECTION_DEFAULT).- Returns:
- whether the engine drives autocommit and commits/rolls back itself
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
mode
-
batches
-