Package org.apache.cayenne.query
Class SQLExec
java.lang.Object
org.apache.cayenne.query.IndirectQuery
org.apache.cayenne.query.SQLExec
- All Implemented Interfaces:
- Serializable,- Query
public class SQLExec extends IndirectQuery
A generic query based on raw SQL and featuring fluent API. While
 
SQLExec can be used to select data (see execute(ObjectContext)
 ), it is normally used for updates, DDL operations, etc.- Since:
- 4.0
- See Also:
- Serialized Form
- 
Field SummaryFields Modifier and Type Field Description protected StringdataMapNameprotected Map<String,Object>paramsprotected List<Object>positionalParamsprotected booleanreturnGeneratedKeysprotected StringBuildersqlBufferFields inherited from class org.apache.cayenne.query.IndirectQuerydataMap, lastResolver, name, replacementQuery
- 
Constructor Summary
- 
Method SummaryModifier and Type Method Description SQLExecappend(String sqlChunk)Appends a piece of SQL to the previously stored SQL template.protected QuerycreateReplacementQuery(EntityResolver resolver)Creates a substitute query.QueryResultexecute(ObjectContext context)Map<String,Object>getParams()Returns a potentially immutable map of named parameters that will be bound to SQL.List<Object>getPositionalParams()Returns a potentially immutable list of positional parameters that will be bound to SQL.StringgetSql()booleanisReturnGeneratedKeys()SQLExecparams(String name, Object value)SQLExecparams(Map<String,?> parameters)SQLExecparamsArray(Object... params)Initializes positional parameters of the query.SQLExecparamsList(List<Object> params)Initializes positional parameters of the query.static SQLExecquery(String sql)Creates a query executing provided SQL run against default database.static SQLExecquery(String dataMapName, String sql)Creates a query executing provided SQL that performs routing based on the provided DataMap name.SQLExecreturnGeneratedKeys(boolean returnGeneratedKeys)Flag indicating that generated keys should be returned by this query execution.intupdate(ObjectContext context)int[]updateBatch(ObjectContext context)Methods inherited from class org.apache.cayenne.query.IndirectQuerycreateSQLAction, getMetaData, getReplacementQuery, route
- 
Field Details- 
dataMapName
- 
sqlBuffer
- 
params
- 
positionalParams
- 
returnGeneratedKeysprotected boolean returnGeneratedKeys
 
- 
- 
Constructor Details- 
SQLExec
 
- 
- 
Method Details- 
queryCreates a query executing provided SQL run against default database.
- 
queryCreates a query executing provided SQL that performs routing based on the provided DataMap name.
- 
getSql
- 
appendAppends a piece of SQL to the previously stored SQL template.
- 
params
- 
params
- 
paramsArrayInitializes positional parameters of the query. Parameters are bound in the order they are found in the SQL template. If a given parameter name is used more than once, only the first occurrence is treated as "position", subsequent occurrences are bound with the same value as the first one. If template parameters count is different from the array parameter count, an exception will be thrown.Note that calling this method will reset any previously set *named* parameters. 
- 
paramsListInitializes positional parameters of the query. Parameters are bound in the order they are found in the SQL template. If a given parameter name is used more than once, only the first occurrence is treated as "position", subsequent occurrences are bound with the same value as the first one. If template parameters count is different from the list parameter count, an exception will be thrown.Note that calling this method will reset any previously set *named* parameters. 
- 
getParamsReturns a potentially immutable map of named parameters that will be bound to SQL.
- 
getPositionalParamsReturns a potentially immutable list of positional parameters that will be bound to SQL.
- 
execute
- 
update
- 
updateBatch
- 
isReturnGeneratedKeyspublic boolean isReturnGeneratedKeys()- Returns:
- returnGeneratedKeys flag value
- Since:
- 4.1
 
- 
returnGeneratedKeysFlag indicating that generated keys should be returned by this query execution. Generated keys could be read viaQueryResponse.currentList()method- Parameters:
- returnGeneratedKeys- flag value
- Since:
- 4.1
- See Also:
- Statement.RETURN_GENERATED_KEYS
 
- 
createReplacementQueryDescription copied from class:IndirectQueryCreates a substitute query. An implementor is free to provide an arbitrary replacement query.- Specified by:
- createReplacementQueryin class- IndirectQuery
 
 
-