@NotThreadSafe public class BatchContext extends Object implements Closeable
batch queries
.Constructor and Description |
---|
BatchContext(Supplier<String> description,
Duration expectedDuration)
Creates a new context with the given debugging description and the expected runtime.
|
Modifier and Type | Method and Description |
---|---|
DeleteQuery<?> |
autoDeleteQuery(String... mappingsToCompare)
Returns an autoinitializing delete query.
|
FindQuery<?> |
autoFindQuery(String... mappingsToCompare)
Returns an autoinitializing find query.
|
InsertQuery<?> |
autoInsertQuery(boolean fetchId,
String... mappingsToInsert)
Returns an autoinitializing insert query.
|
InsertQuery<?> |
autoInsertQuery(String... mappingsToInsert)
Returns an autoinitializing insert query.
|
UpdateQuery<?> |
autoUpdateByIdQuery(String... mappingsToUpdate)
Returns an autoinitializing update query which uses
SQLEntity.ID as mapping to compare. |
UpdateQuery<?> |
autoUpdateQuery(String... mappingsToCompare)
Returns an autoinitializing update query.
|
void |
close() |
protected Connection |
createConnection(String realm) |
CustomQuery |
customQuery(Class<? extends SQLEntity> type,
boolean fetchId,
String sql)
Prepares the given SQL statement as
custom query . |
<E extends SQLEntity> |
deleteQuery(Class<E> type,
Mapping... mappingsToCompare)
Creates a new
delete query . |
<E extends SQLEntity> |
findQuery(Class<E> type,
Mapping... mappingsToCompare)
Creates a
find query . |
protected Connection |
getConnection(String realm) |
<E extends SQLEntity> |
insertQuery(Class<E> type,
boolean fetchId,
Mapping... mappingsToInsert)
Creates a new
insert query . |
<E extends SQLEntity> |
insertQuery(Class<E> type,
Mapping... mappingsToInsert)
Creates a new
insert query . |
protected void |
safeClose() |
protected static String[] |
simplifyMappings(Mapping[] mappingsToCompare) |
String |
toString() |
protected void |
unregister(BatchQuery<?> query) |
<E extends SQLEntity> |
updateByIdQuery(Class<E> type,
Mapping... mappingsToUpdate)
Creates a new
update query which uses SQLEntity.ID as mapping to compare. |
<E extends SQLEntity> |
updateQuery(Class<E> type,
Mapping... mappingsToCompare)
Creates a new
update query . |
public BatchContext(Supplier<String> description, Duration expectedDuration)
description
- a provider for a description used for debugging purposesexpectedDuration
- the expected duration of the whole batch operationprotected void unregister(BatchQuery<?> query)
protected Connection getConnection(String realm)
protected Connection createConnection(String realm)
protected void safeClose()
public <E extends SQLEntity> FindQuery<E> findQuery(Class<E> type, Mapping... mappingsToCompare)
find query
.E
- the generic type of the entities to findtype
- the type of entities to findmappingsToCompare
- the mappings to compare in order to find an entitypublic FindQuery<?> autoFindQuery(String... mappingsToCompare)
Based on the first call passed to FindQuery.find(SQLEntity)
the type of entities to
resolve is determined.
This is used in JavaScript as there is no real notion of class literals. Also it is quite simpler to provide
mappings as string rather than as real Mapping
.
mappingsToCompare
- the mappings to compare in order to find an entitypublic <E extends SQLEntity> InsertQuery<E> insertQuery(Class<E> type, boolean fetchId, Mapping... mappingsToInsert)
insert query
.E
- the generic type of the entities to inserttype
- the type of entities to insertfetchId
- true if generated id should be fetched, false otherwisemappingsToInsert
- the fields or mappings to insertpublic InsertQuery<?> autoInsertQuery(boolean fetchId, String... mappingsToInsert)
fetchId
- true if generated id should be fetched, false otherwisemappingsToInsert
- the fields or mappings to insertautoFindQuery(String...)
public <E extends SQLEntity> InsertQuery<E> insertQuery(Class<E> type, Mapping... mappingsToInsert)
insert query
.E
- the generic type of the entities to inserttype
- the type of entities to insertmappingsToInsert
- the fields or mappings to insertpublic InsertQuery<?> autoInsertQuery(String... mappingsToInsert)
mappingsToInsert
- the fields or mappings to insertautoFindQuery(String...)
public <E extends SQLEntity> UpdateQuery<E> updateQuery(Class<E> type, Mapping... mappingsToCompare)
update query
.E
- the generic type of the entities to updatetype
- the type of entities to updatemappingsToCompare
- the mappings to compare in order to find the entity to updatepublic UpdateQuery<?> autoUpdateQuery(String... mappingsToCompare)
mappingsToCompare
- the mappings to compare in order to find the entity to updateautoFindQuery(String...)
public <E extends SQLEntity> UpdateQuery<E> updateByIdQuery(Class<E> type, Mapping... mappingsToUpdate)
update query
which uses SQLEntity.ID
as mapping to compare.E
- the generic type of the entities to updatetype
- the type of entities to insertmappingsToUpdate
- the mappings to updatepublic UpdateQuery<?> autoUpdateByIdQuery(String... mappingsToUpdate)
SQLEntity.ID
as mapping to compare.mappingsToUpdate
- the mappings to updateautoFindQuery(String...)
public <E extends SQLEntity> DeleteQuery<E> deleteQuery(Class<E> type, Mapping... mappingsToCompare)
delete query
.E
- the generic type of the entities to deletetype
- the type of entities to deletemappingsToCompare
- the mappings to compare in order to find the entity to deletepublic DeleteQuery<?> autoDeleteQuery(String... mappingsToCompare)
mappingsToCompare
- the mappings to compare in order to find the entity to deleteautoFindQuery(String...)
public CustomQuery customQuery(Class<? extends SQLEntity> type, boolean fetchId, String sql)
custom query
.type
- the type of entities to processfetchId
- determines if generated IDs should be fetchedsql
- the statement to preparepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2018. All rights reserved.