Package de.businesscode.bcdui.wrs.load
Class SqlFromSubSelect
java.lang.Object
de.businesscode.bcdui.wrs.load.SqlFromSubSelect
Takes a single wrq:Select (formally a "sub-select") and turns it into a SQLStatementWithParams
Each select taking part in UNIONs or being a sub-select is represented by an instance of this class.
It uses WrqInfo to collect all necessary information from the WRQ XML
There is a 1:1 relationship between SqlFromSubSelect and WrqInfo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,WrqBindingSet> These BindingSets are our main BindingSet and all joined ones, i.e, all listed in our wrq:Fromprotected final SqlFromSubSelectprotected WrqBindingSetFromDerivedTableA virtual BindingSet representing the result set created by this sub-selectprotected Set<StandardBindingSet>All Standard BindingSets, which we or any of our sub-selects are usingprotected intprotected intprotected final Elementprotected SQLStatementWithParamsprotected final WrqInfoprotected final WrqQueryBuilder -
Constructor Summary
ConstructorsConstructorDescriptionSqlFromSubSelect(WrqQueryBuilder wrqQueryBuilder, SqlFromSubSelect parent, Element selectElem) We are initialized for a full-select (SELECTSs connected with SET operators). -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddBindingSetForWrqAlias(String wrqAlias, WrqBindingSet bindingSet) Set the BindingSet for a user-provided table expression aliasprotected voidHandles a "select-statement", i.e. a complete selectprotected voidgenerateFromClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Generates 'FROM' and the tables with their join expressionprotected voidgenerateGroupingClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Generates Grouping clauseprotected voidgenerateHavingClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Generates Having SQL clauseprotected voidgenerateOffsetFetchClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Optionally append 'OFFSET 10 FETCH NEXT 20 ROWS ONLY' for paginationprotected voidgenerateOrderClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Generates Order-By clauseprotected voidgenerateSelectClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Generates 'SELECT' plus the select listprotected voidgenerateWhereClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) Generates 'WHERE' plus the filterAccess to parent select, which may be null This is used, for example, to look up referenced columnsA BindingSet representing our result set as if we were a bnd:BindingSetAccess to the current overall query, there is only one per WrqRetrieve a BindingItem bRef with alias from the current scope, i.e, the local wrq:From or any wrq:From from outer selects or CTEsresolveBindingSetFromScope(String wrqAlias) Get the (Virtual)BindingSet for a user-provided table expression wrq alias.
-
Field Details
-
selectElem
-
wrqQueryBuilder
-
parent
-
wrqInfo
-
rowStart
protected int rowStart -
rowEnd
protected int rowEnd -
resolvedBindingSets
All Standard BindingSets, which we or any of our sub-selects are using -
representingBindingSet
A virtual BindingSet representing the result set created by this sub-select -
bindingSetForWrqAlias
These BindingSets are our main BindingSet and all joined ones, i.e, all listed in our wrq:From -
selectStatement
-
-
Constructor Details
-
SqlFromSubSelect
public SqlFromSubSelect(WrqQueryBuilder wrqQueryBuilder, SqlFromSubSelect parent, Element selectElem) throws Exception We are initialized for a full-select (SELECTSs connected with SET operators).- Parameters:
wrqQueryBuilder-selectElem-- Throws:
Exception
-
-
Method Details
-
createSelectStatement
Handles a "select-statement", i.e. a complete select- Throws:
Exception- See Also:
-
generateSelectClause
protected void generateSelectClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws BindingNotFoundException Generates 'SELECT' plus the select list- Throws:
BindingNotFoundException
-
generateFromClause
protected void generateFromClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws BindingException Generates 'FROM' and the tables with their join expression- Throws:
BindingException
-
generateWhereClause
protected void generateWhereClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws Exception Generates 'WHERE' plus the filter -
generateGroupingClause
protected void generateGroupingClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws Exception Generates Grouping clause- Throws:
Exception
-
generateHavingClause
protected void generateHavingClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws Exception Generates Having SQL clause- Parameters:
wrqInfo-sqlStatement-- Throws:
XPathExpressionExceptionBindingExceptionException
-
generateOrderClause
protected void generateOrderClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws BindingNotFoundException Generates Order-By clause- Throws:
BindingNotFoundException
-
generateOffsetFetchClause
protected void generateOffsetFetchClause(WrqInfo wrqInfo, SQLStatementWithParams sqlStatement) throws BindingNotFoundException Optionally append 'OFFSET 10 FETCH NEXT 20 ROWS ONLY' for pagination- Parameters:
wrqInfo-sqlStatement-- Throws:
BindingNotFoundException
-
getBoundVariables
-
getSelectedBindingItems
-
getRepresentingBindingSet
A BindingSet representing our result set as if we were a bnd:BindingSet- Returns:
- Throws:
Exception
-
getWrqInfo
-
getResolvedBindingSets
-
getSelectStatement
-
resolveBindingSetFromScope
Get the (Virtual)BindingSet for a user-provided table expression wrq alias. Can be a BindingSet or a sub-select acting as a table expression. It can also be a (Virtual)BindingSet in an outer Select or a Cte.- Parameters:
wrqAlias- the wrq table alias- Returns:
- Throws:
BindingNotFoundException
-
resolveBindingItemFromScope
Retrieve a BindingItem bRef with alias from the current scope, i.e, the local wrq:From or any wrq:From from outer selects or CTEs- Parameters:
bRef- including wrq table alias- Returns:
- Throws:
BindingNotFoundException
-
addBindingSetForWrqAlias
Set the BindingSet for a user-provided table expression alias- Parameters:
wrqAlias-bindingSet-
-
getWrqQueryBuilder
Access to the current overall query, there is only one per Wrq- Returns:
-
getParent
Access to parent select, which may be null This is used, for example, to look up referenced columns- Returns:
-
getSelectElem
-