|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.AbstractQuery net.sf.basedb.core.AbstractSqlQuery
abstract class AbstractSqlQuery
An abstract implementation of the SqlQuery
interface.
Field Summary | |
---|---|
private static boolean |
debugParamEnabled
So we don't always have to call logParam.debug() |
private static boolean |
debugSqlEnabled
So we don't always have to call logSql.debug() |
private static Logger |
logParam
Log all parameter bindings to prepared statement. |
private static Logger |
logSql
Log all SQL statements. |
private static Pattern |
namedParameter
Pattern that finds a named parameter in an SQL string. |
Constructor Summary | |
---|---|
AbstractSqlQuery(String rootEntity)
|
Method Summary | |
---|---|
(package private) String |
bindLimits(String sql,
List<String> parameterOrder)
Parse the given SQL and add LIMIT and OFFSET parameters to it. |
long |
count(DbControl dc)
Count the number of items/rows that are returned by the query. |
(package private) abstract Select[] |
getDefaultSelects()
|
QueryType |
getQueryType()
Get the type of query. |
DynamicResultIterator |
iterate(DbControl dc)
Execute the query. |
(package private) String |
parseParameters(String sql,
List<String> parameterOrder)
Parse the given SQL and find named parameters. |
(package private) void |
setParameters(PreparedStatement ps,
List<String> parameterOrder)
Set parameter values on a prepared statement. |
private void |
setParameterValue(PreparedStatement ps,
int index,
Object parameterValue,
Type valueType)
Set a parameter value on a prepared statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.query.Query |
---|
addAutoJoiner, getFirstResult, getMaxResults, getParameterNames, getQueryParameter, getQuerySection, getRootAlias, group, groupPermanent, hasParameterValue, having, havingPermanent, isCounting, isDistinct, isReadonly, isReturningTotalCount, join, joinPermanent, order, orderPermanent, reset, restrict, restrictPermanent, select, selectPermanent, setDistinct, setFirstResult, setMaxResults, setParameter, setPermanentParameter, setReturnTotalCount, toQl |
Field Detail |
---|
private static final Logger logSql
private static final boolean debugSqlEnabled
private static final Logger logParam
private static final boolean debugParamEnabled
private static final Pattern namedParameter
Constructor Detail |
---|
AbstractSqlQuery(String rootEntity)
Method Detail |
---|
public QueryType getQueryType()
Query
getQueryType
in interface Query
QueryType.SQL
public long count(DbControl dc) throws BaseException
Query
Query.getFirstResult()
and Query.getMaxResults()
settings.
count
in interface Query
BaseException
- If there is an errorabstract Select[] getDefaultSelects()
public DynamicResultIterator iterate(DbControl dc) throws BaseException
dc
- The DbControl
to use for database access
DynamicResultIterator
object
BaseException
- If there is an errorString parseParameters(String sql, List<String> parameterOrder)
sql
- The original SQL string, which may contain named
parametersparameterOrder
- A list that should store the name of the
parameters in the correct order
String bindLimits(String sql, List<String> parameterOrder)
Dialect
and uses it for generating the actual SQL. If limit parameters are added
to the query this method adds entries for those parameters in the
parameterOrder
list and values using the regular
Query.setParameter(String, Object, Type)
method.
The parameter names used are _limit_
and _offset_
.
If the underlying database doesn't support limit parameters the query
will be executed and the result starting point moved forward to the
correct offset and the a limit will be passed to the DynamicResultIterator
object.
sql
- The original SQL without limit parametersparameterOrder
- A list that stores the names of the parameters
in the order they should be binf by JDBC
void setParameters(PreparedStatement ps, List<String> parameterOrder) throws SQLException
ps
- The prepared statementparameterOrder
- The names of the parameters in the order they
appear in the prepared statement
SQLException
private void setParameterValue(PreparedStatement ps, int index, Object parameterValue, Type valueType) throws SQLException
BasicItem
the id of the object is used a value.
ps
- The prepared statementindex
- The index of the parameter, starting at 1parameterValue
- The value of the parameter
SQLException
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |