E
- the type of entities being processed by this query.public abstract class BatchQuery<E extends SQLEntity> extends Object
PreparedStatement
to be used within a BatchContext
.Modifier and Type | Field and Description |
---|---|
protected sirius.kernel.health.Average |
avarage |
protected int |
batchBacklog |
protected int |
batchBacklogLimit |
protected BatchContext |
context |
protected EntityDescriptor |
descriptor |
protected String[] |
mappings |
static int |
MAX_BATCH_BACKLOG
Defines the default batch size used by a query.
|
protected static Mixing |
mixing |
protected static OMA |
oma |
protected List<Property> |
properties |
protected String |
query |
protected PreparedStatement |
stmt |
protected Class<E> |
type |
Modifier | Constructor and Description |
---|---|
protected |
BatchQuery(BatchContext context,
Class<E> type,
String[] mappings)
Creates a new instance for the given context, type and mappings.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addBatch()
Adds the current parameter set as batch.
|
protected abstract void |
buildSQL()
Determines the SQL statement to prepare in
prepareStmt() . |
void |
close()
Closes the query by executing the last batch and releasing all resources.
|
void |
commit()
Forces a batch to be processed (independent of it size, as long as it isn't empty).
|
protected void |
createStmt(String sql,
boolean returnGeneratedKeys)
Prepares a new statement for the given sql and options.
|
protected EntityDescriptor |
getDescriptor()
Determines the descriptor for the our entity type.
|
protected List<Property> |
getProperties()
Transforms the mappings into a list of properties.
|
protected PreparedStatement |
prepareStmt()
Prepares a new statement if not done already.
|
protected void |
safeClose()
Releases all resources with graceful error handling
|
String |
toString() |
protected void |
tryCommit(boolean cascade) |
void |
withCustomBatchLimit(int maxBacklog)
Specifies a custom batch size for this query.
|
public static final int MAX_BATCH_BACKLOG
protected BatchContext context
protected PreparedStatement stmt
protected int batchBacklog
protected int batchBacklogLimit
protected final String[] mappings
protected EntityDescriptor descriptor
protected String query
protected sirius.kernel.health.Average avarage
protected static OMA oma
protected static Mixing mixing
protected BatchQuery(BatchContext context, Class<E> type, String[] mappings)
context
- the batch context to participate intype
- the type of entities being processedmappings
- the mappings to processpublic void withCustomBatchLimit(int maxBacklog)
maxBacklog
- the max. batch size to processprotected void tryCommit(boolean cascade)
public void commit()
protected void addBatch() throws SQLException
SQLException
- in case of a database errorprotected void createStmt(String sql, boolean returnGeneratedKeys) throws SQLException
sql
- the statement to preparereturnGeneratedKeys
- determines if generated key should be returned or notSQLException
- in case of a database errorprotected PreparedStatement prepareStmt() throws SQLException
SQLException
- in case of a database errorprotected abstract void buildSQL() throws SQLException
prepareStmt()
.SQLException
- in case of a database errorprotected EntityDescriptor getDescriptor()
protected List<Property> getProperties()
public void close()
protected void safeClose()
Copyright © 2018. All rights reserved.