public abstract class Prepared
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
create
Whether to create a new object (for indexes).
|
protected java.util.ArrayList<Parameter> |
parameters
The list of parameters.
|
protected boolean |
prepareAlways
If the query should be prepared before each execution.
|
protected SessionLocal |
session
The session.
|
protected java.lang.String |
sqlStatement
The SQL string.
|
protected java.util.ArrayList<Token> |
sqlTokens
The SQL tokens.
|
Constructor and Description |
---|
Prepared(SessionLocal session)
Create a new object.
|
Modifier and Type | Method and Description |
---|---|
void |
checkCanceled()
Check if this statement was canceled.
|
protected void |
checkParameters()
Check if all parameters have been set.
|
void |
collectDependencies(java.util.HashSet<DbObject> dependencies)
Find and collect all DbObjects, this Prepared depends on.
|
java.util.List<TableView> |
getCteCleanups() |
long |
getCurrentRowNumber()
Get the current row number.
|
protected Database |
getDatabase() |
protected int |
getObjectId()
Get the current object id, or get a new id from the database.
|
java.util.ArrayList<Parameter> |
getParameters()
Get the parameter list.
|
int |
getPersistedObjectId()
Get the object id to use for the database object that is created in this
statement.
|
java.lang.String |
getPlanSQL(int sqlFlags)
Get the SQL statement with the execution plan.
|
SessionLocal |
getSession() |
static java.lang.String |
getSimpleSQL(Expression[] list)
Get the SQL snippet of the expression list.
|
java.lang.String |
getSQL()
Get the SQL statement.
|
java.util.ArrayList<Token> |
getSQLTokens()
Get the SQL tokens.
|
abstract int |
getType()
Get the command type as defined in CommandInterface
|
boolean |
isCacheable() |
boolean |
isQuery()
Check if this object is a query.
|
boolean |
isReadOnly()
Check if this command is read only.
|
boolean |
isRetryable()
Returns is this command can be repeated again on locking failure.
|
abstract boolean |
isTransactional()
Check if this command is transactional.
|
boolean |
isWithParamValues()
Returns whether values of parameters were specified in SQL.
|
boolean |
needRecompile()
Check if the statement needs to be re-compiled.
|
void |
prepare()
Prepare this statement.
|
ResultInterface |
query(long maxrows)
Execute the query.
|
abstract ResultInterface |
queryMeta()
Get an empty result set containing the meta data.
|
void |
setCommand(Command command)
Set the command.
|
void |
setCteCleanups(java.util.List<TableView> cteCleanups)
Set the temporary views created for CTE's.
|
void |
setCurrentRowNumber(long rowNumber)
Set the current row number.
|
void |
setParameterList(java.util.ArrayList<Parameter> parameters)
Set the parameter list of this statement.
|
void |
setPersistedObjectId(int i)
Set the persisted object id for this statement.
|
void |
setPrepareAlways(boolean prepareAlways)
Set the prepare always flag.
|
protected DbException |
setRow(DbException e,
long rowId,
java.lang.String values)
Set the SQL statement of the exception to the given row.
|
void |
setSession(SessionLocal currentSession)
Set the session for this statement.
|
void |
setSQL(java.lang.String sql,
java.util.ArrayList<Token> sqlTokens)
Set the SQL statement.
|
void |
setWithParamValues(boolean withParamValues)
Sets whether values of parameters were specified in SQL.
|
java.lang.String |
toString()
Convert the statement to a String.
|
long |
update()
Execute the statement.
|
protected SessionLocal session
protected java.lang.String sqlStatement
protected java.util.ArrayList<Token> sqlTokens
protected boolean create
protected java.util.ArrayList<Parameter> parameters
protected boolean prepareAlways
public Prepared(SessionLocal session)
session
- the sessionpublic abstract boolean isTransactional()
public abstract ResultInterface queryMeta()
public abstract int getType()
public boolean isReadOnly()
public boolean needRecompile()
public void setParameterList(java.util.ArrayList<Parameter> parameters)
parameters
- the parameter listpublic java.util.ArrayList<Parameter> getParameters()
public boolean isWithParamValues()
public void setWithParamValues(boolean withParamValues)
withParamValues
- are values of parameters were specified in SQLprotected void checkParameters()
DbException
- if any parameter has not been setpublic void setCommand(Command command)
command
- the new commandpublic boolean isQuery()
public void prepare()
public long update()
DbException
- if it is a querypublic ResultInterface query(long maxrows)
maxrows
- the maximum number of rows to returnDbException
- if it is not a querypublic final void setSQL(java.lang.String sql, java.util.ArrayList<Token> sqlTokens)
sql
- the SQL statementsqlTokens
- the SQL tokenspublic final java.lang.String getSQL()
public final java.util.ArrayList<Token> getSQLTokens()
public int getPersistedObjectId()
protected int getObjectId()
public java.lang.String getPlanSQL(int sqlFlags)
sqlFlags
- formatting flagspublic void checkCanceled()
DbException
- if it was canceledpublic void setPersistedObjectId(int i)
i
- the object idpublic void setSession(SessionLocal currentSession)
currentSession
- the new sessionpublic void setPrepareAlways(boolean prepareAlways)
prepareAlways
- the new valuepublic void setCurrentRowNumber(long rowNumber)
rowNumber
- the row numberpublic long getCurrentRowNumber()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String getSimpleSQL(Expression[] list)
list
- the expression listprotected final DbException setRow(DbException e, long rowId, java.lang.String values)
e
- the exceptionrowId
- the row numbervalues
- the values of the rowpublic boolean isCacheable()
public java.util.List<TableView> getCteCleanups()
public void setCteCleanups(java.util.List<TableView> cteCleanups)
cteCleanups
- the temporary viewspublic final SessionLocal getSession()
public void collectDependencies(java.util.HashSet<DbObject> dependencies)
dependencies
- collection of dependencies to populateprotected final Database getDatabase()
public boolean isRetryable()