Package com.querydsl.sql.dml
Class AbstractSQLInsertClause<C extends AbstractSQLInsertClause<C>>
java.lang.Object
com.querydsl.sql.dml.AbstractSQLClause<C>
com.querydsl.sql.dml.AbstractSQLInsertClause<C>
- Type Parameters:
C- The type extending this class.
- All Implemented Interfaces:
DMLClause<C>,InsertClause<C>,StoreClause<C>
- Direct Known Subclasses:
SQLInsertClause
public abstract class AbstractSQLInsertClause<C extends AbstractSQLInsertClause<C>>
extends AbstractSQLClause<C>
implements InsertClause<C>
Provides a base class for dialect-specific INSERT clauses.
- Author:
- tiwe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<SQLInsertBatch>protected booleanprotected final RelationalPath<?>protected static final Loggerprotected final QueryMetadataprotected Stringprotected @Nullable SubQueryExpression<?>protected @Nullable SQLQuery<?>protected final List<Expression<?>>Fields inherited from class com.querydsl.sql.dml.AbstractSQLClause
configuration, context, listeners, useLiterals -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSQLInsertClause(Connection connection, Configuration configuration, RelationalPath<?> entity) AbstractSQLInsertClause(Connection connection, Configuration configuration, RelationalPath<?> entity, SQLQuery<?> subQuery) AbstractSQLInsertClause(Supplier<Connection> connection, Configuration configuration, RelationalPath<?> entity) AbstractSQLInsertClause(Supplier<Connection> connection, Configuration configuration, RelationalPath<?> entity, SQLQuery<?> subQuery) -
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 flagvoidclear()Clear the internal state of the clauseprotected PreparedStatementcreateStatement(boolean withKeys) protected Collection<PreparedStatement>createStatements(boolean withKeys) longexecute()<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) intgetSQL()Get the SQL string and bindingsbooleanisEmpty()Populate the INSERT clause with the properties of the given bean.<T> CPopulate the INSERT clause with the properties of the given bean using the given Mapper.protected PreparedStatementprepareStatementAndSetParameters(SQLSerializer serializer, boolean withKeys) select(SubQueryExpression<?> sq) <T> Cset(Path<T> path, Expression<? extends T> expression) <T> CvoidsetBatchToBulk(boolean b) Set whether batches should be optimized into a single bulk operation.<T> CtoString()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
-
entity
-
metadata
-
subQuery
-
subQueryBuilder
-
batches
-
columns
-
values
-
queryString
-
constants
-
batchToBulk
protected transient boolean batchToBulk
-
-
Constructor Details
-
AbstractSQLInsertClause
public AbstractSQLInsertClause(Connection connection, Configuration configuration, RelationalPath<?> entity, SQLQuery<?> subQuery) -
AbstractSQLInsertClause
public AbstractSQLInsertClause(Connection connection, Configuration configuration, RelationalPath<?> entity) -
AbstractSQLInsertClause
public AbstractSQLInsertClause(Supplier<Connection> connection, Configuration configuration, RelationalPath<?> entity, SQLQuery<?> subQuery) -
AbstractSQLInsertClause
public AbstractSQLInsertClause(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
-
addBatch
Add the current state of bindings as a batch item- Returns:
- the current object
-
setBatchToBulk
public void setBatchToBulk(boolean b) Set whether batches should be optimized into a single bulk operation. Will revert to batches, if bulk is not supported -
clear
public void clear()Description copied from class:AbstractSQLClauseClear the internal state of the clause- Specified by:
clearin classAbstractSQLClause<C extends AbstractSQLInsertClause<C>>
-
columns
- Specified by:
columnsin interfaceInsertClause<C extends AbstractSQLInsertClause<C>>
-
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
-
createStatement
- Throws:
SQLException
-
createStatements
- Throws:
SQLException
-
prepareStatementAndSetParameters
protected PreparedStatement prepareStatementAndSetParameters(SQLSerializer serializer, boolean withKeys) throws SQLException - Throws:
SQLException
-
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<C extends AbstractSQLInsertClause<C>>
-
getSQL
Description copied from class:AbstractSQLClauseGet the SQL string and bindings- Specified by:
getSQLin classAbstractSQLClause<C extends AbstractSQLInsertClause<C>>- Returns:
- SQL and bindings
-
select
- Specified by:
selectin interfaceInsertClause<C extends AbstractSQLInsertClause<C>>
-
set
- Specified by:
setin interfaceStoreClause<C extends AbstractSQLInsertClause<C>>
-
set
- Specified by:
setin interfaceStoreClause<C extends AbstractSQLInsertClause<C>>
-
setNull
- Specified by:
setNullin interfaceStoreClause<C extends AbstractSQLInsertClause<C>>
-
values
- Specified by:
valuesin interfaceInsertClause<C extends AbstractSQLInsertClause<C>>
-
toString
-
populate
Populate the INSERT clause with the properties of the given bean. The properties need to match the fields of the clause's entity instance.- Parameters:
bean- bean to use for population- Returns:
- the current object
-
populate
Populate the INSERT clause with the properties of the given bean using the given Mapper.- Parameters:
obj- object to use for populationmapper- mapper to use- Returns:
- the current object
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceStoreClause<C extends AbstractSQLInsertClause<C>>
-
getBatchCount
public int getBatchCount()- Specified by:
getBatchCountin classAbstractSQLClause<C extends AbstractSQLInsertClause<C>>
-