|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.6.0) E13403-07 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SQLQueryBuilder
Interface that defines a builder class for sql queries. A builder is responsible for one SQLQuery, and as long as it is used to perform ALL edit operations on that query will be able to maintain a knowledge of all the Relations and Columns used in that query. If the query is edited without using the builder then the builder's support can no longer be relied upon.
Convention used for method names:
Nested Class Summary | |
---|---|
static interface |
SQLQueryBuilder.SQLQueryObjectSet
A result set interface for the query builder class |
Method Summary | |
---|---|
void |
addFromObject(FromObject from)
Adds the given FromObject to the query. |
void |
addGroupByColumn(FromObjectUsage colu)
Adds the given FromObjectUsage to the end of the GROUP BY clause. |
void |
addGroupByColumn(int index,
FromObjectUsage colu)
Adds the given FromObjectUsage to the specified index of the GROUP BY clause. |
void |
addOrderByObject(int index,
OrderByObject ob)
Adds the given order by object to the given index in the clause. |
void |
addOrderByObject(OrderByObject ob)
Adds the given order by object to the end of the order by clause. |
void |
addSelectObject(int index,
SelectObject select)
Inserts the given SelectObject to the query at the given index. |
void |
addSelectObject(SelectObject select)
Adds the given SelectObject to the query. |
void |
buildQuery(SQLQuery query)
Builds the query based on the given SQLQuery. |
void |
buildQuery(java.lang.String select)
Builds the query based on the given select statement. |
void |
buildQuery(java.lang.String select,
SQLQueryOwner owner)
Builds the query based on the given select statement. |
boolean |
canMergeRelationUsages(RelationUsage baseUsage,
RelationUsage mergingUsage)
Determines whether the two RelationUsages are based on the same table. |
boolean |
canSetGroupBy()
Returns true if this query can accept a group by clause. |
SQLQueryBuilder.SQLQueryObjectSet |
constructFKJoin(FKConstraint fk,
FromObject left,
FromObject right)
Creates a JOIN in the query's FROM clause to represent the given FKConstraint. |
SQLQueryBuilder.SQLQueryObjectSet |
constructFKJoins(FKConstraint[] fks,
FromObject[] usagesToUse)
Creates a set of nested JOINs in the query's FROM clause to represent each given FKConstraint. |
SQLQueryBuilder.SQLQueryObjectSet |
constructFromObject(Relation relation,
boolean createSelectObjects,
boolean createJoins,
FromObject[] includeInJoins)
Creates a FromObject for the query. |
FromObject |
constructFromObject(java.lang.String expression,
java.lang.String alias)
Creates a FromObject using the given alias and expression, parsing the expression into an appropriate set of SQLFragments. |
SQLQueryBuilder.SQLQueryObjectSet |
constructFromObjects(Relation[] baseRelations,
boolean createSelectObjects,
boolean createJoins,
FromObject[] includeInJoins)
Creates one or more FromObjects for the query. |
SQLQueryBuilder.SQLQueryObjectSet |
constructSelectObject(Column col,
FromObject usageToUse)
Creates a SelectObject for the query based on the column passed in. |
SelectObject |
constructSelectObject(java.lang.String expression,
java.lang.String alias)
Creates a SelectObject using the given alias and expression, parsing the expression into an appropriate set of SQLFragments. |
SQLQueryBuilder.SQLQueryObjectSet |
constructSelectObjects(Column[] baseCols,
FromObject[] usagesToUse)
Creates a set of SelectObjects for the query based on the columns passed in. |
java.lang.String |
createUniqueFromAlias(java.lang.String base)
Takes the given base for an alias and returns an alias that will be unique within this builder's query. |
java.lang.String |
createUniqueSelectAlias(java.lang.String base)
Takes the given base for an alias and returns an alias that will be unique within this builder's query. |
FunctionDefinition[] |
getBuiltInFunctions()
|
ColumnUsage[] |
getColumnUsages()
Returns all the ColumnUsage objects that are present in this query's SELECT and WHERE clauses. |
SQLFragment[] |
getDependentObjects(FromObject from)
Returns all objects that are dependent on the given FromObject. |
SQLFragment[] |
getDependentObjects(SelectObject select)
Returns all objects that are dependent on the given SelectObject. |
FromObject |
getFromObject(java.lang.String usableAlias)
Returns the from object that can be referenced by this alias. |
RelationUsage[] |
getRelationUsages()
Returns the RelationUsages found in the SQLQuery. |
SelectObject |
getSelectObject(java.lang.String usableAlias)
Returns the select object that can be referenced by this alias. |
AbstractSQLQuery |
getSQLQuery()
Returns the query that this builder is working on. |
boolean |
isUniqueFromAlias(java.lang.String alias)
Returns true if this alias is unique within the builder's query. |
boolean |
isUniqueSelectAlias(java.lang.String alias)
Returns true if this alias is unique within the builder's query. |
FromObject[] |
listAllFromObjects()
Returns all FromObjects in the FROM clause including those nested in JOIN conditions. |
FromObject[] |
listAllFromObjects(boolean includeJoins)
Returns all FromObjects in the FROM clause including those nested in JOIN conditions. |
FKUsage[] |
listAvailableFKs()
Returns all the FKs that could join the relations used in the view wrapped up in an FKUsage so as to include the appropriate FromObjects. |
void |
mergeRelationUsages(RelationUsage baseUsage,
RelationUsage mergingUsage)
Merges two RelationUsages into one. |
SQLFragment |
parseFromExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a From object. |
SQLFragment |
parseHavingExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Having object. |
OnJoinCondition |
parseOnExpression(java.lang.String expression,
JoinObject join)
More specific than parseFromExpression() this method is used to specifically parse the ON expression for a JOIN in a FROM clause. |
SQLFragment |
parseOrderByExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Order By object. |
SQLFragment |
parseSelectExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Select object. |
SQLFragment |
parseWhereExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Where object. |
boolean |
removeFromObject(FromObject obj)
Removes the given FromObject from the SQLQuery. |
boolean |
removeGroupByColumn(FromObjectUsage colu)
Removes the given FromObjectUsage from the GROUP BY clause. |
boolean |
removeJoinObject(FromObject obj)
If the expression for the given obj is a JoinObject the join is removed and the two FromObjects that were joined are added to the top level of the query. |
boolean |
removeOrderByObject(OrderByObject ob)
Removes the given order by object from the orderby clause. |
boolean |
removeSelectObject(SelectObject obj)
Removes the given SelectObject from the SQLQuery. |
void |
replaceFromObject(FromObject oldFrom,
FromObject newFrom)
Replaces the existing from object with a new one. |
void |
replaceOrderByObject(OrderByObject oldOb,
OrderByObject newOb)
Replaces the existing from object with a new one. |
void |
replaceSelectObject(SelectObject oldSelect,
SelectObject newSelect)
Replaces the existing select object with a new one. |
void |
setGroupByObject(GroupByObject obj)
Sets the group by object. |
void |
setHavingObject(WhereObject having)
Sets the HAVING clause of the query. |
void |
setHierarchicalQueryObject(HierarchicalQueryObject having)
Sets the CONNECT BY clause of the query. |
void |
setOrderByObjects(OrderByObject[] orderbys)
Sets the order by objects for the query. |
void |
setWhereObject(WhereObject where)
Sets the WhereObject on the query (whilst caching any appropriate dependencies). |
boolean |
supportsConnectBy()
Returns whether the given builder flavour supports the Hierarchical Query clause (CONNECT BY) Allows for builders of less featured DBs to restrict the query editing capabilities. |
boolean |
supportsGroupBy()
Returns wether the given builder flavour supports the GROUP BY clause. |
boolean |
supportsOrderBy()
Returns wether the given builder flavour supports the ORDER BY clause. |
void |
syncViewColumns()
If the query is a View query ( @see isViewQuery() ) this syncs the SelectObjects in the query with the Columns in the View. |
void |
validateQuery()
Validates a query object to check that its internal structure is correct. |
Method Detail |
---|
AbstractSQLQuery getSQLQuery()
void validateQuery() throws SQLQueryException
SQLQueryException
- if the query fails to validate.void buildQuery(java.lang.String select) throws SQLQueryException
SQLQueryException
- if the query cannot be built.void buildQuery(java.lang.String select, SQLQueryOwner owner) throws SQLQueryException
the
- owner for this query (the query will not be set on the owner).
SQLQueryException
- if the query cannot be built.void buildQuery(SQLQuery query) throws SQLQueryException
SQLQueryException
- if the query cannot be built.SQLFragment parseSelectExpression(java.lang.String expression) throws SQLQueryException
expression
- the sql to parse as a SELECT fragment.
SQLQueryException
void addSelectObject(SelectObject select) throws SQLQueryException
SQLQueryException
void addSelectObject(int index, SelectObject select) throws SQLQueryException
SQLQueryException
boolean isUniqueSelectAlias(java.lang.String alias)
SelectObject getSelectObject(java.lang.String usableAlias)
ColumnUsage[] getColumnUsages()
java.lang.String createUniqueSelectAlias(java.lang.String base)
SelectObject constructSelectObject(java.lang.String expression, java.lang.String alias) throws SQLQueryException
expression
- the sql for the SelectObjectalias
- the alias for the SelectObject
SQLQueryException
SQLQueryBuilder.SQLQueryObjectSet constructSelectObject(Column col, FromObject usageToUse) throws SQLQueryException
col
- the column to use as the base of the new SelectObject.usageToUse
- A FromObjects in the query that may be used
while creating the SelectObject. If null, then a relation usage will be
created by default.
SQLQueryException
- if the select object cannot be built.SQLQueryBuilder.SQLQueryObjectSet constructSelectObjects(Column[] baseCols, FromObject[] usagesToUse) throws SQLQueryException
baseCols
- An array of columns to be the base columns of the new
SelectObjects.usagesToUse
- An array of FromObjects in the query that may be used
while creating the SelectObjects. If null, then relation usages will be
created by default.
SQLQueryException
- if the select objects cannot be built.boolean removeSelectObject(SelectObject obj)
obj
- the SelectObject to remove.
void replaceSelectObject(SelectObject oldSelect, SelectObject newSelect) throws SQLQueryException
SQLQueryException
SQLFragment[] getDependentObjects(SelectObject select)
select
- the object to get the dependencies for
SQLFragment parseFromExpression(java.lang.String expression) throws SQLQueryException
expression
- the sql to parse as a FROM fragment.
SQLQueryException
OnJoinCondition parseOnExpression(java.lang.String expression, JoinObject join) throws SQLQueryException
expression
- the sql to parse as an ON conditionjoin
- the JOIN whose condition we are parsing
SQLQueryException
void addFromObject(FromObject from) throws SQLQueryException
SQLQueryException
boolean isUniqueFromAlias(java.lang.String alias)
FromObject[] listAllFromObjects()
FromObject[] listAllFromObjects(boolean includeJoins)
includeJoins
- if set to true, FromObjects for JOINs will be included
in the returned array
java.lang.String createUniqueFromAlias(java.lang.String base)
FromObject getFromObject(java.lang.String usableAlias)
FromObject constructFromObject(java.lang.String expression, java.lang.String alias) throws SQLQueryException
expression
- the sql for the FromObjectalias
- the alias for the FromObject
SQLQueryException
SQLQueryBuilder.SQLQueryObjectSet constructFromObject(Relation relation, boolean createSelectObjects, boolean createJoins, FromObject[] includeInJoins) throws SQLQueryException
relation
- A table or view from which to create the new RelationUsage.createSelectObjects
- If true, a SelectObject is created for each
column in the base relation.createJoins
- If true, a WhereObject is created for each foreign key
between tables in the array of relations.includeInJoins
- Whether or not the createJoins parameter is set to
true, any foreign key between the base relation of these FromObjects and
a relation in the baseRelations parameter causes the relevant
WhereObject to be created. This parameter can be null.
SQLQueryException
- if the from objects cannot be built.SQLQueryBuilder.SQLQueryObjectSet constructFromObjects(Relation[] baseRelations, boolean createSelectObjects, boolean createJoins, FromObject[] includeInJoins) throws SQLQueryException
baseRelations
- An array of tables and views from which to create
the new RelationUsages.createSelectObjects
- If true, a SelectObject is created for each
column in the base relation.createJoins
- If true, a WhereObject is created for each foreign key
between tables in the array of relations.includeInJoins
- Whether or not the createJoins parameter is set to
true, any foreign key between the base relation of these FromObjects and
a relation in the baseRelations parameter causes the relevant
WhereObject to be created. This parameter can be null.
SQLQueryException
- if the from objects cannot be built.boolean removeJoinObject(FromObject obj)
boolean removeFromObject(FromObject obj)
obj
- the FromObject to remove.
void replaceFromObject(FromObject oldFrom, FromObject newFrom) throws SQLQueryException
SQLQueryException
RelationUsage[] getRelationUsages()
SQLFragment[] getDependentObjects(FromObject from)
In the case of nested objects the top level object will be returned. For
example the following SelectObject: NVL(E.COMM, 0)
has a
nested ColumnUsage which is dependent on the FromObject with alias "E".
Calling this method on that FromObject will return the SelectObject, not
the nested ColumnUsage.
from
- the FromObject to get the dependencies for
boolean canMergeRelationUsages(RelationUsage baseUsage, RelationUsage mergingUsage)
baseUsage
- The RelationUsage that will remain and form the
basis of the new usage after the mergemergingUsage
- The RelationUsage which will be removed as
part of the merge. Any relevant WhereObjects and SelectObjects
will be made to reference the new merged usage.
void mergeRelationUsages(RelationUsage baseUsage, RelationUsage mergingUsage) throws SQLQueryException
baseUsage
- The RelationUsage that will remain and form the
basis of the new usage after the mergemergingUsage
- The RelationUsage which will be removed as
part of the merge. Any relevant WhereObjects and SelectObjects
will be made to reference the new merged usage.
SQLQueryException
- if an error occurs merging the relations.SQLFragment parseWhereExpression(java.lang.String expression) throws SQLQueryException
expression
- the sql to parse as a WHERE fragment.
SQLQueryException
SQLQueryBuilder.SQLQueryObjectSet constructFKJoin(FKConstraint fk, FromObject left, FromObject right) throws SQLQueryException
fk
- the foreign key constraint to creat a join forleft
- the left hand expression for the join to be created.right
- the right hand expression for the join to be created.
SQLQueryException
SQLQueryBuilder.SQLQueryObjectSet constructFKJoins(FKConstraint[] fks, FromObject[] usagesToUse) throws SQLQueryException
fks
- the foreign key constraints to creat joins for, in order.usagesToUse
- an array of FromObjects to use for the JOIN. If the
relations in question aren't in the array new FromObjects will be created
as necessary
SQLQueryException
void setWhereObject(WhereObject where)
where
- the query's new WhereObjectFKUsage[] listAvailableFKs()
boolean supportsConnectBy()
void setHierarchicalQueryObject(HierarchicalQueryObject having)
boolean supportsGroupBy()
boolean canSetGroupBy()
void setGroupByObject(GroupByObject obj)
void addGroupByColumn(FromObjectUsage colu)
void addGroupByColumn(int index, FromObjectUsage colu)
boolean removeGroupByColumn(FromObjectUsage colu)
SQLFragment parseHavingExpression(java.lang.String expression) throws SQLQueryException
expression
- the sql to parse as a HAVING fragment.
SQLQueryException
void setHavingObject(WhereObject having)
boolean supportsOrderBy()
SQLFragment parseOrderByExpression(java.lang.String expression) throws SQLQueryException
expression
- the sql to parse as a ORDER BY fragment.
SQLQueryException
void addOrderByObject(OrderByObject ob)
void addOrderByObject(int index, OrderByObject ob)
boolean removeOrderByObject(OrderByObject ob)
void replaceOrderByObject(OrderByObject oldOb, OrderByObject newOb)
void setOrderByObjects(OrderByObject[] orderbys)
FunctionDefinition[] getBuiltInFunctions()
void syncViewColumns() throws AliasInUseException
AliasInUseException
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.6.0) E13403-07 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |