Package com.im.commons.db.dml
Class SQLSelectStatement
- java.lang.Object
-
- com.im.commons.db.dml.SQLSelectStatement
-
public final class SQLSelectStatement extends java.lang.Object
A SQL select builder of some sort. TODO - change to use Visitor pattern to allow for flexible SQL generation TODO - add support for things like SELECT *, SELECT count(*) TODO - add full support for joins in where clauses TODO - allow better support for bound params- Author:
- Tim Dudgeon
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SQLSelectStatement
addSelectElement(SQLSelectElement element)
SQLSelectStatement
addWhereClauseElement(SQLWhereClauseElement where, SQLWhereClauseCompositeElement.Type type)
Add the specified element to those that make up the currnet where clause.java.lang.String
generateSql()
SQLGroupByClause
getGroupByClause()
SQLOrderByClause
getOrderByClause()
Getter for property orderByClause.java.util.List<? extends SQLSelectElement>
getSelectElements()
SQLWhereClauseElement
getWhereClause()
Get the current where clause.boolean
isDistinct()
boolean
isOrderByColsMustBeInSelectCols()
Get the value of orderByColsMustBeInSelectCols.void
setDistinct(boolean b)
-
-
-
Method Detail
-
isOrderByColsMustBeInSelectCols
public boolean isOrderByColsMustBeInSelectCols()
Get the value of orderByColsMustBeInSelectCols.- Returns:
- The value of orderByColsMustBeInSelectCols
-
isDistinct
public boolean isDistinct()
-
setDistinct
public void setDistinct(boolean b)
-
getSelectElements
public java.util.List<? extends SQLSelectElement> getSelectElements()
-
getOrderByClause
public SQLOrderByClause getOrderByClause()
Getter for property orderByClause.- Returns:
- Value of property orderByClause.
-
getGroupByClause
public SQLGroupByClause getGroupByClause()
-
addSelectElement
public SQLSelectStatement addSelectElement(SQLSelectElement element)
-
getWhereClause
public SQLWhereClauseElement getWhereClause()
Get the current where clause. Not that adding to this can rearrange the where clause elements so if in doubt set the rearranged caluse back using @{link #setWhereClause} or (better) use the @{link addWhereClauseElement} method that automatically handles this.- Returns:
- The current where claus
-
addWhereClauseElement
public SQLSelectStatement addWhereClauseElement(SQLWhereClauseElement where, SQLWhereClauseCompositeElement.Type type)
Add the specified element to those that make up the currnet where clause. The element will be added to the where exisiting elements as needed, re-arranging the clause if necessary.- Parameters:
where
- The element to addtype
- Whether to add as AND or OR- Returns:
- "this" so that additions can be chained.
-
generateSql
public java.lang.String generateSql()
-
-