Package com.querydsl.sql.dml
Class SQLMergeClause
- All Implemented Interfaces:
DMLClause<SQLMergeClause>,StoreClause<SQLMergeClause>
public class SQLMergeClause
extends AbstractSQLClause<SQLMergeClause>
implements StoreClause<SQLMergeClause>
SQLMergeClause defines an MERGE INTO clause- Author:
- tiwe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<SQLMergeBatch>protected final RelationalPath<?>protected static final Loggerprotected final QueryMetadataprotected Stringprotected @Nullable SubQueryExpression<?>protected final List<Expression<?>>Fields inherited from class com.querydsl.sql.dml.AbstractSQLClause
configuration, context, listeners, useLiterals -
Constructor Summary
ConstructorsConstructorDescriptionSQLMergeClause(Connection connection, Configuration configuration, RelationalPath<?> entity) SQLMergeClause(Connection connection, SQLTemplates templates, RelationalPath<?> entity) SQLMergeClause(Supplier<Connection> connection, Configuration configuration, RelationalPath<?> entity) -
Method Summary
Modifier and TypeMethodDescriptionaddBatch()Add the current state of bindings as a batch itemaddFlag(QueryFlag.Position position, Expression<?> flag) Add the given Expression at the given position as a query flagaddFlag(QueryFlag.Position position, String flag) Add the given String literal at the given position as a query flagprotected voidaddKeyConditions(FilteredClause<?> query) protected voidaddListeners(AbstractSQLClause<?> clause) voidclear()Clear the internal state of the clauseprotected PreparedStatementcreateStatement(boolean withKeys) protected Collection<PreparedStatement>createStatements(boolean withKeys) longexecute()protected longprotected long<T> TexecuteWithKey(Path<T> path) Execute the clause and return the generated key with the type of the given path.<T> TexecuteWithKey(Class<T> type) Execute the clause and return the generated key cast to the given type.protected <T> TexecuteWithKey(Class<T> type, @Nullable Path<T> path) Execute the clause and return the generated keys as a ResultSet<T> List<T>executeWithKeys(Path<T> path) Execute the clause and return the generated key with the type of the given path.<T> List<T>executeWithKeys(Class<T> type) protected <T> List<T>executeWithKeys(Class<T> type, @Nullable Path<T> path) intgetKeys()getSQL()Get the SQL string and bindingsprotected booleanhasRow()booleanisEmpty()Set the keys to be used in the MERGE clauseprotected voidpopulate(StoreClause<?> clause) protected PreparedStatementprepareStatementAndSetParameters(SQLSerializer serializer, boolean withKeys) select(SubQueryExpression<?> subQuery) <T> SQLMergeClauseset(Path<T> path, Expression<? extends T> expression) <T> SQLMergeClause<T> SQLMergeClausetoString()Methods inherited from class com.querydsl.sql.dml.AbstractSQLClause
addListener, close, close, close, connection, createBindings, createSerializer, endContext, executeBatch, logQuery, onException, reset, setParameters, setUseLiterals, startContext
-
Field Details
-
logger
-
columns
-
entity
-
metadata
-
keys
-
subQuery
-
batches
-
values
-
queryString
-
constants
-
-
Constructor Details
-
SQLMergeClause
-
SQLMergeClause
-
SQLMergeClause
public SQLMergeClause(Supplier<Connection> connection, Configuration configuration, RelationalPath<?> entity)
-
-
Method Details
-
addFlag
Add the given String literal at the given position as a query flag- Parameters:
position- positionflag- query flag- Returns:
- the current object
-
addFlag
Add the given Expression at the given position as a query flag- Parameters:
position- positionflag- query flag- Returns:
- the current object
-
getKeys
-
addBatch
Add the current state of bindings as a batch item- Returns:
- the current object
-
clear
public void clear()Description copied from class:AbstractSQLClauseClear the internal state of the clause- Specified by:
clearin classAbstractSQLClause<SQLMergeClause>
-
columns
-
executeWithKey
Execute the clause and return the generated key with the type of the given path. If no rows were created, null is returned, otherwise the key of the first row is returned.- Type Parameters:
T-- Parameters:
path- path for key- Returns:
- generated key
-
executeWithKey
Execute the clause and return the generated key cast to the given type. If no rows were created, null is returned, otherwise the key of the first row is returned.- Type Parameters:
T-- Parameters:
type- type of key- Returns:
- generated key
-
executeWithKey
-
executeWithKeys
Execute the clause and return the generated key with the type of the given path. If no rows were created, or the referenced column is not a generated key, null is returned. Otherwise, the key of the first row is returned.- Type Parameters:
T-- Parameters:
path- path for key- Returns:
- generated keys
-
executeWithKeys
-
executeWithKeys
-
executeWithKeys
Execute the clause and return the generated keys as a ResultSet- Returns:
- result set with generated keys
-
execute
public long execute()- Specified by:
executein interfaceDMLClause<SQLMergeClause>
-
getSQL
Description copied from class:AbstractSQLClauseGet the SQL string and bindings- Specified by:
getSQLin classAbstractSQLClause<SQLMergeClause>- Returns:
- SQL and bindings
-
hasRow
protected boolean hasRow() -
addKeyConditions
-
executeCompositeMerge
protected long executeCompositeMerge() -
addListeners
-
populate
-
createStatement
- Throws:
SQLException
-
createStatements
- Throws:
SQLException
-
prepareStatementAndSetParameters
protected PreparedStatement prepareStatementAndSetParameters(SQLSerializer serializer, boolean withKeys) throws SQLException - Throws:
SQLException
-
executeNativeMerge
protected long executeNativeMerge() -
keys
Set the keys to be used in the MERGE clause- Parameters:
paths- keys- Returns:
- the current object
-
select
-
set
- Specified by:
setin interfaceStoreClause<SQLMergeClause>
-
set
- Specified by:
setin interfaceStoreClause<SQLMergeClause>
-
setNull
- Specified by:
setNullin interfaceStoreClause<SQLMergeClause>
-
toString
-
values
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceStoreClause<SQLMergeClause>
-
getBatchCount
public int getBatchCount()- Specified by:
getBatchCountin classAbstractSQLClause<SQLMergeClause>
-