public interface LoaderOptionsStep<R extends Record> extends LoaderSourceStep<R>
Loader
API is used for configuring data loads.
Add options to for the loading behaviour. For performance reasons, you can fine-tune three different types of measures:
INSERT
statement.Modifier and Type | Method and Description |
---|---|
LoaderOptionsStep<R> |
batchAfter(int number)
Batch a given number of bulk statements together.
|
LoaderOptionsStep<R> |
batchAll()
Batch all bulk statements in one JDBC batch statement.
|
LoaderOptionsStep<R> |
batchNone()
Do not batch bulk statements together.
|
LoaderOptionsStep<R> |
bulkAfter(int number)
Bulk-insert a given number of statements in a single multi-row bulk
statement.
|
LoaderOptionsStep<R> |
bulkAll()
Bulk-insert all rows in a single multi-row bulk statement.
|
LoaderOptionsStep<R> |
bulkNone()
Do not bulk-insert rows in multi-row bulk statements.
|
LoaderOptionsStep<R> |
commitAfter(int number)
Commit after a certain number of batches.
|
LoaderOptionsStep<R> |
commitAll()
Commit only after inserting all batches.
|
LoaderOptionsStep<R> |
commitEach()
Commit each batch.
|
LoaderOptionsStep<R> |
commitNone()
Leave committing / rollbacking up to client code.
|
LoaderOptionsStep<R> |
onDuplicateKeyError()
Instruct the
Loader to cause an error in loading if there
are any duplicate records. |
LoaderOptionsStep<R> |
onDuplicateKeyIgnore()
Instruct the
Loader to skip duplicate records if the main
unique key's value is already in the database. |
LoaderOptionsStep<R> |
onDuplicateKeyUpdate()
Instruct the
Loader to update duplicate records if the main
unique key's value is already in the database. |
LoaderOptionsStep<R> |
onErrorAbort()
Instruct the
Loader to abort loading after the first error
that might occur when inserting a record. |
LoaderOptionsStep<R> |
onErrorIgnore()
Instruct the
Loader to ignore any errors that might occur
when inserting a record. |
loadArrays, loadArrays, loadArrays, loadArrays, loadCSV, loadCSV, loadCSV, loadCSV, loadCSV, loadCSV, loadCSV, loadCSV, loadCSV, loadCSV, loadJSON, loadJSON, loadJSON, loadJSON, loadJSON, loadJSON, loadJSON, loadJSON, loadJSON, loadJSON, loadRecords, loadRecords, loadRecords, loadRecords, loadXML, loadXML, loadXML, loadXML, loadXML, loadXML, loadXML, loadXML, loadXML, loadXML, loadXML
@Support(value={CUBRID,DB2,HSQLDB,MARIADB,MYSQL,ORACLE,POSTGRES_9_5,SQLSERVER,SYBASE}) LoaderOptionsStep<R> onDuplicateKeyUpdate()
Loader
to update duplicate records if the main
unique key's value is already in the database. This is only supported if
InsertQuery.onDuplicateKeyUpdate(boolean)
is supported, too.
If the loaded table does not have a primary key, then all records are
inserted and this clause behaves like onDuplicateKeyIgnore()
If you don't specify a behaviour, onDuplicateKeyError()
will be
the default. This cannot be combined with onDuplicateKeyError()
or onDuplicateKeyIgnore()
@Support LoaderOptionsStep<R> onDuplicateKeyIgnore()
Loader
to skip duplicate records if the main
unique key's value is already in the database.
If the loaded table does not have a primary key, then all records are
inserted. This may influence the JDBC driver's outcome on
Connection.getWarnings()
, depending on your JDBC driver's
implementation
If you don't specify a behaviour, onDuplicateKeyError()
will be
the default. This cannot be combined with onDuplicateKeyError()
or onDuplicateKeyUpdate()
@Support LoaderOptionsStep<R> onDuplicateKeyError()
Loader
to cause an error in loading if there
are any duplicate records.
If this is combined with onErrorAbort()
and commitAll()
in a later step of Loader
, then loading is rollbacked on
abort.
If you don't specify a behaviour, this will be the default. This cannot
be combined with onDuplicateKeyIgnore()
or
onDuplicateKeyUpdate()
@Support LoaderOptionsStep<R> onErrorIgnore()
Loader
to ignore any errors that might occur
when inserting a record. The Loader
will then skip the
record and try inserting the next one. After loading, you can access
errors with Loader.errors()
If you don't specify a behaviour, onErrorAbort()
will be the
default. This cannot be combined with onErrorAbort()
@Support LoaderOptionsStep<R> onErrorAbort()
Loader
to abort loading after the first error
that might occur when inserting a record. After loading, you can access
errors with Loader.errors()
If this is combined with commitAll()
in a later step of
Loader
, then loading is rollbacked on abort.
If you don't specify a behaviour, this will be the default. This cannot
be combined with onErrorIgnore()
@Support LoaderOptionsStep<R> commitEach()
This is the same as calling commitAfter(int)
with 1
as parameter.
With this clause, errors will never result in a rollback, even when you
specify onDuplicateKeyError()
or onErrorAbort()
The COMMIT OPTIONS might be useful for fine-tuning performance behaviour
in some RDBMS, where large commits lead to a high level of concurrency in
the database. Use this on fresh transactions only. Commits/Rollbacks are
executed directly upon the connection returned by
Configuration.connectionProvider()
. This might not work with
container-managed transactions, or when
Connection.getAutoCommit()
is set to true.
If you don't specify a COMMIT OPTION, commitNone()
will be the
default, leaving transaction handling up to you.
@Support LoaderOptionsStep<R> commitAfter(int number)
With this clause, errors will never result in a rollback, even when you
specify onDuplicateKeyError()
or onErrorAbort()
The COMMIT OPTIONS might be useful for fine-tuning performance behaviour
in some RDBMS, where large commits lead to a high level of concurrency in
the database. Use this on fresh transactions only. Commits/Rollbacks are
executed directly upon the connection returned by
Configuration.connectionProvider()
. This might not work with
container-managed transactions, or when
Connection.getAutoCommit()
is set to true.
If you don't specify a COMMIT OPTION, commitNone()
will be the
default, leaving transaction handling up to you.
number
- The number of records that are committed together.@Support LoaderOptionsStep<R> commitAll()
onDuplicateKeyError()
or onErrorAbort()
, an abort will
result in a rollback of previously loaded records.
The COMMIT OPTIONS might be useful for fine-tuning performance behaviour
in some RDBMS, where large commits lead to a high level of concurrency in
the database. Use this on fresh transactions only. Commits/Rollbacks are
executed directly upon the connection returned by
Configuration.connectionProvider()
. This might not work with
container-managed transactions, or when
Connection.getAutoCommit()
is set to true.
If you don't specify a COMMIT OPTION, commitNone()
will be the
default, leaving transaction handling up to you.
@Support LoaderOptionsStep<R> commitNone()
The COMMIT OPTIONS might be useful for fine-tuning performance behaviour in some RDBMS, where large commits lead to a high level of concurrency in the database.
If you don't specify a COMMIT OPTION, this will be the default, leaving
transaction handling up to you. This should be your choice, when you use
container-managed transactions, too, or your
Connection.getAutoCommit()
value is set to true.
@Support LoaderOptionsStep<R> batchAll()
If commitEach()
or commitAfter(int)
are set, this will
force the COMMIT
option to commitAll()
.
@Support LoaderOptionsStep<R> batchNone()
If you don't specify a BATCH OPTION, this will be the default.
@Support LoaderOptionsStep<R> batchAfter(int number)
number
- The number of records that are batched together.@Support LoaderOptionsStep<R> bulkAll()
If commitEach()
or commitAfter(int)
are set, this will
force the COMMIT
option to commitAll()
.
@Support LoaderOptionsStep<R> bulkNone()
If you don't specify a BULK OPTION, this will be the default.
@Support LoaderOptionsStep<R> bulkAfter(int number)
If commitEach()
is set, each bulk statement will be committed.
If commitAfter(int)
is set, the given number of bulk statements
are committed.
number
- The number of records that are put together in one bulk
statement.Copyright © 2016. All Rights Reserved.