public class SQLExec extends IndirectQuery
SQLExec
can be used to select data (see execute(ObjectContext)
), it is normally used for updates, DDL operations, etc.Modifier and Type | Field and Description |
---|---|
protected String |
dataMapName |
protected Map<String,Object> |
params |
protected List<Object> |
positionalParams |
protected boolean |
returnGeneratedKeys |
protected StringBuilder |
sqlBuffer |
dataMap, lastResolver, name, replacementQuery
Modifier and Type | Method and Description |
---|---|
SQLExec |
append(String sqlChunk)
Appends a piece of SQL to the previously stored SQL template.
|
protected Query |
createReplacementQuery(EntityResolver resolver)
Creates a substitute query.
|
QueryResult |
execute(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.
|
String |
getSql() |
boolean |
isReturnGeneratedKeys() |
SQLExec |
params(Map<String,?> parameters) |
SQLExec |
params(String name,
Object value) |
SQLExec |
paramsArray(Object... params)
Initializes positional parameters of the query.
|
SQLExec |
paramsList(List<Object> params)
Initializes positional parameters of the query.
|
static SQLExec |
query(String sql)
Creates a query executing provided SQL run against default database.
|
static SQLExec |
query(String dataMapName,
String sql)
Creates a query executing provided SQL that performs routing based on the
provided DataMap name.
|
SQLExec |
returnGeneratedKeys(boolean returnGeneratedKeys)
Flag indicating that generated keys should be returned by this query execution.
|
int |
update(ObjectContext context) |
int[] |
updateBatch(ObjectContext context) |
createSQLAction, getMetaData, getReplacementQuery, route
protected String dataMapName
protected StringBuilder sqlBuffer
protected boolean returnGeneratedKeys
public SQLExec(String sql)
public static SQLExec query(String sql)
public static SQLExec query(String dataMapName, String sql)
public String getSql()
public SQLExec append(String sqlChunk)
public SQLExec paramsArray(Object... params)
Note that calling this method will reset any previously set *named* parameters.
public SQLExec paramsList(List<Object> params)
Note that calling this method will reset any previously set *named* parameters.
public Map<String,Object> getParams()
public List<Object> getPositionalParams()
public QueryResult execute(ObjectContext context)
public int update(ObjectContext context)
public int[] updateBatch(ObjectContext context)
public boolean isReturnGeneratedKeys()
public SQLExec returnGeneratedKeys(boolean returnGeneratedKeys)
QueryResponse.currentList()
methodreturnGeneratedKeys
- flag valueStatement.RETURN_GENERATED_KEYS
protected Query createReplacementQuery(EntityResolver resolver)
IndirectQuery
createReplacementQuery
in class IndirectQuery
Copyright © 2001–2019 Apache Cayenne. All rights reserved.