public class SQLMergeClause extends AbstractSQLClause<SQLMergeClause> implements StoreClause<SQLMergeClause>
SQLMergeClause
defines an MERGE INTO clauseModifier and Type | Field and Description |
---|---|
protected java.util.List<SQLMergeBatch> |
batches |
protected java.util.List<Path<?>> |
columns |
protected java.util.List<java.lang.Object> |
constants |
protected RelationalPath<?> |
entity |
protected java.util.List<Path<?>> |
keys |
protected static java.util.logging.Logger |
logger |
protected QueryMetadata |
metadata |
protected java.lang.String |
queryString |
protected @Nullable SubQueryExpression<?> |
subQuery |
protected java.util.List<Expression<?>> |
values |
configuration, context, listeners, useLiterals
Constructor and Description |
---|
SQLMergeClause(java.sql.Connection connection,
Configuration configuration,
RelationalPath<?> entity) |
SQLMergeClause(java.sql.Connection connection,
SQLTemplates templates,
RelationalPath<?> entity) |
SQLMergeClause(java.util.function.Supplier<java.sql.Connection> connection,
Configuration configuration,
RelationalPath<?> entity) |
Modifier and Type | Method and Description |
---|---|
SQLMergeClause |
addBatch()
Add the current state of bindings as a batch item
|
SQLMergeClause |
addFlag(QueryFlag.Position position,
Expression<?> flag)
Add the given Expression at the given position as a query flag
|
SQLMergeClause |
addFlag(QueryFlag.Position position,
java.lang.String flag)
Add the given String literal at the given position as a query flag
|
protected void |
addKeyConditions(FilteredClause<?> query) |
protected void |
addListeners(AbstractSQLClause<?> clause) |
void |
clear()
Clear the internal state of the clause
|
SQLMergeClause |
columns(Path<?>... columns) |
protected java.sql.PreparedStatement |
createStatement(boolean withKeys) |
protected java.util.Collection<java.sql.PreparedStatement> |
createStatements(boolean withKeys) |
long |
execute()
Execute the clause and return the amount of affected rows
|
protected long |
executeCompositeMerge() |
protected long |
executeNativeMerge() |
<T> T |
executeWithKey(java.lang.Class<T> type)
Execute the clause and return the generated key cast to the given type.
|
protected <T> T |
executeWithKey(java.lang.Class<T> type,
@Nullable Path<T> path) |
<T> T |
executeWithKey(Path<T> path)
Execute the clause and return the generated key with the type of the given path.
|
java.sql.ResultSet |
executeWithKeys()
Execute the clause and return the generated keys as a ResultSet
|
<T> java.util.List<T> |
executeWithKeys(java.lang.Class<T> type) |
protected <T> java.util.List<T> |
executeWithKeys(java.lang.Class<T> type,
@Nullable Path<T> path) |
<T> java.util.List<T> |
executeWithKeys(Path<T> path)
Execute the clause and return the generated key with the type of the given path.
|
int |
getBatchCount() |
protected java.util.List<? extends Path<?>> |
getKeys() |
java.util.List<SQLBindings> |
getSQL()
Get the SQL string and bindings
|
protected boolean |
hasRow() |
boolean |
isEmpty()
Returns true, if no bindings have been set, otherwise false.
|
SQLMergeClause |
keys(Path<?>... paths)
Set the keys to be used in the MERGE clause
|
protected void |
populate(StoreClause<?> clause) |
protected java.sql.PreparedStatement |
prepareStatementAndSetParameters(SQLSerializer serializer,
boolean withKeys) |
SQLMergeClause |
select(SubQueryExpression<?> subQuery) |
<T> SQLMergeClause |
set(Path<T> path,
Expression<? extends T> expression)
Add an expression binding
|
<T> SQLMergeClause |
set(Path<T> path,
T value)
Add a value binding
|
<T> SQLMergeClause |
setNull(Path<T> path)
Bind the given path to null
|
java.lang.String |
toString() |
SQLMergeClause |
values(java.lang.Object... v) |
addListener, close, close, close, connection, createBindings, createSerializer, endContext, executeBatch, logQuery, onException, reset, setParameters, setUseLiterals, startContext
protected static final java.util.logging.Logger logger
protected final java.util.List<Path<?>> columns
protected final RelationalPath<?> entity
protected final QueryMetadata metadata
protected final java.util.List<Path<?>> keys
@Nullable protected @Nullable SubQueryExpression<?> subQuery
protected final java.util.List<SQLMergeBatch> batches
protected final java.util.List<Expression<?>> values
protected transient java.lang.String queryString
protected transient java.util.List<java.lang.Object> constants
public SQLMergeClause(java.sql.Connection connection, SQLTemplates templates, RelationalPath<?> entity)
public SQLMergeClause(java.sql.Connection connection, Configuration configuration, RelationalPath<?> entity)
public SQLMergeClause(java.util.function.Supplier<java.sql.Connection> connection, Configuration configuration, RelationalPath<?> entity)
public SQLMergeClause addFlag(QueryFlag.Position position, java.lang.String flag)
position
- positionflag
- query flagpublic SQLMergeClause addFlag(QueryFlag.Position position, Expression<?> flag)
position
- positionflag
- query flagprotected java.util.List<? extends Path<?>> getKeys()
public SQLMergeClause addBatch()
public void clear()
AbstractSQLClause
clear
in class AbstractSQLClause<SQLMergeClause>
public SQLMergeClause columns(Path<?>... columns)
@Nullable public <T> T executeWithKey(Path<T> path)
T
- path
- path for keypublic <T> T executeWithKey(java.lang.Class<T> type)
T
- type
- type of keyprotected <T> T executeWithKey(java.lang.Class<T> type, @Nullable @Nullable Path<T> path)
public <T> java.util.List<T> executeWithKeys(Path<T> path)
T
- path
- path for keypublic <T> java.util.List<T> executeWithKeys(java.lang.Class<T> type)
protected <T> java.util.List<T> executeWithKeys(java.lang.Class<T> type, @Nullable @Nullable Path<T> path)
public java.sql.ResultSet executeWithKeys()
public long execute()
DMLClause
execute
in interface DMLClause<SQLMergeClause>
public java.util.List<SQLBindings> getSQL()
AbstractSQLClause
getSQL
in class AbstractSQLClause<SQLMergeClause>
protected boolean hasRow()
protected void addKeyConditions(FilteredClause<?> query)
protected long executeCompositeMerge()
protected void addListeners(AbstractSQLClause<?> clause)
protected void populate(StoreClause<?> clause)
protected java.sql.PreparedStatement createStatement(boolean withKeys) throws java.sql.SQLException
java.sql.SQLException
protected java.util.Collection<java.sql.PreparedStatement> createStatements(boolean withKeys) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.PreparedStatement prepareStatementAndSetParameters(SQLSerializer serializer, boolean withKeys) throws java.sql.SQLException
java.sql.SQLException
protected long executeNativeMerge()
public SQLMergeClause keys(Path<?>... paths)
paths
- keyspublic SQLMergeClause select(SubQueryExpression<?> subQuery)
public <T> SQLMergeClause set(Path<T> path, @Nullable T value)
StoreClause
set
in interface StoreClause<SQLMergeClause>
path
- path to be updatedvalue
- value to setpublic <T> SQLMergeClause set(Path<T> path, Expression<? extends T> expression)
StoreClause
set
in interface StoreClause<SQLMergeClause>
path
- path to be updatedexpression
- bindingpublic <T> SQLMergeClause setNull(Path<T> path)
StoreClause
setNull
in interface StoreClause<SQLMergeClause>
path
- path to be updatedpublic java.lang.String toString()
toString
in class java.lang.Object
public SQLMergeClause values(java.lang.Object... v)
public boolean isEmpty()
StoreClause
isEmpty
in interface StoreClause<SQLMergeClause>
public int getBatchCount()
getBatchCount
in class AbstractSQLClause<SQLMergeClause>
Copyright © 2007–2021 Querydsl. All rights reserved.