public abstract class AbstractSQLQueryBuilder extends DerivedPropertyBuilder<SQLQuery> implements SQLQueryBuilder
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractSQLQueryBuilder.QueryColumnInfo |
AbstractDBObjectBuilder.PropertyBuilderSQLQueryBuilder.SQLQueryObjectSet| Modifier and Type | Field and Description |
|---|---|
protected static SQLFragment[] |
EMPTY_ARRAY |
BASE_COMPONENT_KEY| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSQLQueryBuilder(DBObjectProvider pro, Schema defaultSchema)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClauseException(SQLQueryClauseException sce)
Caches a clause exception so that it can be re-thrown after the build has finished.
|
protected void |
addExtraObject(SystemObject obj) |
void |
addFromObject(FromObject from)
Adds the given FromObject to the query.
|
protected void |
addFromObjects(FromObject[] froms) |
void |
addGroupByColumn(int index, SQLFragment colu)
Adds the given FromObjectUsage to the specified index of the GROUP BY clause.
|
void |
addGroupByColumn(SQLFragment colu)
Adds the given FromObjectUsage to the end of the GROUP BY clause.
|
protected void |
addJoinObject(FromObject from) |
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.
|
protected void |
addSelectObjects(SelectObject[] selects) |
void |
buildDeclarativeProperties(SQLQuery query)
DerivedPropertyBuilder mechanism that directly builds the derived properties on the given SQLQuery.
|
void |
buildQuery(SQLQuery query)
Builds the query based on the given SQLQuery.
|
void |
buildQuery(java.lang.String sql)
Builds a query object from the given sql expression.
|
void |
buildQuery(java.lang.String sql, SQLQueryOwner parent)
Builds a query from the given sql expression.
|
protected abstract void |
buildQueryImpl(java.lang.String sql, SQLQuery query, SQLQueryOwner parent)
Builds the declarative components of the given SQLQuery 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.
|
void |
checkUsageQualifications()
Checks that every FromObjectUsage which isn't qualified is a unique name within the query.
|
java.util.Collection<java.lang.String> |
clearDerivedProperties(SQLQuery obj, java.lang.String property, DBObjectChange change)
Clears the properties that are derived from the given property and that need resetting given the new value for the source property.
|
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(SchemaObject 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.
|
protected abstract boolean |
containsAsterisk() |
protected FKUsage |
createFKUsage(DBObjectID fkID, FromObject left, FromObject right) |
SQLFragment |
createFromFactory(SQLFragment parent, java.lang.String clause, java.lang.Integer offset) |
protected FromObject |
createFromObject(SchemaObject rel, java.util.List<java.lang.String> extraNames) |
protected JoinCondition |
createJoinCondition(FKConstraint fk, JoinObject join)
Constructs a condition to represent the given FK for the given join.
|
FromObject |
createJoinObject(FKConstraint fk, FromObject left, FromObject right)
Creates a FromObject that joins using a JoinCondition matching the given FK and joins the two from objects.
|
protected SelectObject |
createSelectObject(DBObjectID colId, FromObject from, java.lang.String alias) |
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.
|
protected java.lang.String |
createUniqueFromAlias(java.lang.String base, java.util.List<java.lang.String> extraNames) |
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.
|
protected java.lang.String |
createUniqueSelectAlias(java.lang.String base, java.util.List<java.lang.String> extraNames) |
protected FKUsage |
doConstructFKUsage(FKConstraint fk, java.util.Map relsIDsToUse, java.util.List<FromObject> newFroms) |
protected FromObject |
doConstructFromObject(SchemaObject relation, java.util.List<DBObjectID> baseRelIDs, java.util.List<java.lang.String> relNames, java.util.Map<DBObjectID,FromObject> newRels, java.util.List<Column> cols, java.util.List<FKConstraint> fks) |
protected FromObject |
doConstructJoin(FKConstraint fk, java.util.Map<DBObjectID,FromObject> relsIDsToUse, java.util.List<FromObject> newFroms, FromObject left, FromObject right) |
protected SelectObject |
doConstructSelectObject(Column col, java.util.Map<DBObjectID,FromObject> relsToUse, java.util.Map<DBObjectID,FromObject> newRels, java.util.List<java.lang.String> relNames, java.util.List<java.lang.String> colNames) |
DBObjectID |
ensureID(DBObject frag)
Only call on an object that has been added to the hierarchy - e.g.
|
protected void |
ensureIDs(SQLFragment... frags) |
protected FromObjectUsage |
findColumnInColumnUsage(java.lang.String colName, boolean external, ColumnUsage colu, FromObject from)
Finds a column in the given ColumnUsage.
|
FromObjectUsage |
findColumnInFromExpression(java.lang.String colName, boolean external, SQLFragment exp, boolean allowDuplicates, FromObject from, SQLFragment creating)
Finds a Column of given name in the given FromObject's expression.
|
protected FromObjectUsage |
findColumnInFromObjects(java.lang.String colName, boolean external, FromObject[] froms, boolean allowDuplicates, boolean enforceInAll, SQLFragment creating)
Finds a Column of given name amongst the given FromObjects.
|
FromObjectUsage |
findColumnInFromObjects(java.lang.String colName, boolean external, SQLFragment creating, FromObject... extraFroms)
Finds a Column of given name amongst the RelationUsages in the query.
|
protected FromObjectUsage |
findColumnInJoin(java.lang.String colName, boolean external, JoinObject join, boolean allowDuplicates, SQLFragment creating)
Finds a column in the child FromObjects of a given JoinObject.
|
FromObjectUsage |
findColumnInRelation(java.lang.String colName, boolean external, Relation rel)
Finds a Column with the given name in a Relation and returns a FromObjectUsage that references that column.
|
FromObjectUsage |
findColumnInRelation(java.lang.String colName, boolean external, RelationUsage relU)
Finds a Column with the given name in the Relation referred to by the given RelationUsage, and returns a FromObjectUsage that references that column.
|
ColumnUsage |
findColumnInStarSubQuery(java.lang.String colName, boolean external, FromObject from)
The from object is of the form (SELECT * FROM <rel>) <alias>
|
SelectObjectUsage |
findColumnInSubQuery(java.lang.String colName, boolean external, SQLQuery query) |
java.lang.String |
getColumnName(SelectObject sel) |
Column[] |
getColumns()
Retrieves Column objects mapped to the columns in the SQL query that has been built, thereby giving the name and type of each column the query has.
|
ColumnUsage[] |
getColumnUsages()
Deprecated.
|
protected Schema |
getDefaultSchema() |
SQLFragment[] |
getDependentObjects(FromObject from)
Gets the objects in the query that are dependent on the given from object.
|
SQLFragment[] |
getDependentObjects(SelectObject select)
Gets the objects in the query that are dependent on the given select object.
|
protected abstract DerivedPropertyBuilder |
getDTUBuilder(int columnIndex)
Sublass implementations to provide a DerivedPropertyBuilder capable of building the DataTypeUsage property for Views/MatViews.
|
protected java.lang.String |
getExternalName(java.lang.String name) |
FromObject |
getFromObject(java.lang.String usableAlias)
Returns the from object that can be referenced by this alias.
|
FromObject |
getFromObject(java.lang.String usableAlias, FromObject extrafrom)
Gets a FromObject with the given alias.
|
protected java.util.List<DBObjectID> |
getIDs(DBObject[] objs) |
protected java.lang.String |
getInternalName(java.lang.String name) |
protected java.util.logging.Logger |
getLogger() |
protected SchemaObject |
getObject(DBObjectCriteria crit) |
protected SchemaObject |
getObject(java.lang.String type, Schema sch, java.lang.String relation) |
protected SQLQuery |
getQuery() |
abstract java.util.List<AbstractSQLQueryBuilder.QueryColumnInfo> |
getQueryColumnInfos()
Obtains information about the select list items for use in building view and materialized view columns without building the query unless absolutely necessary.
|
RelationUsage[] |
getRelationUsages()
Returns the RelationUsages found in the FROM clause of the SQLQuery.
|
protected java.util.Map<DBObjectID,FromObject> |
getRelIDs(FromObject[] usagesToUse) |
SelectObject |
getSelectObject(java.lang.String usableAlias)
Returns the select object that can be referenced by this alias.
|
SQLQuery |
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.
|
protected boolean |
isUniqueFromAlias(java.lang.String alias, java.util.List<java.lang.String> extraNames) |
boolean |
isUniqueSelectAlias(java.lang.String alias)
Returns true if this alias is unique within the builder's query.
|
protected boolean |
isUniqueSelectAlias(java.lang.String alias, java.util.List<java.lang.String> extraNames) |
protected boolean |
isValidName(java.lang.String type, java.lang.String name) |
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.
|
protected void |
loadObject(DBObject frag)
Load the given object (i.e.
|
protected void |
loadObjects(DBObject[] frags) |
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.
|
protected SQLFragment |
parseFromExpression(java.lang.String expression, FromObject creating) |
SQLFragment |
parseHavingExpression(java.lang.String expression)
By default this calls parseWhereExpression().
|
SQLFragment |
parseOrderByExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Order By object.
|
protected SQLFragment |
parseOrderByExpression(java.lang.String expression, OrderByObject obo) |
SQLFragment |
parseSelectExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Select object.
|
protected SQLFragment |
parseSelectExpression(java.lang.String expression, SelectObject creating) |
SQLFragment |
parseWhereExpression(java.lang.String expression)
Parses an expression to see if it is a valid expression for a Where object.
|
SQLFragment |
parseWhereExpression(java.lang.String expression, WhereObject creating) |
protected void |
registerAllSQLFragmentFactories(AbstractSQLQueryBuilder builder) |
void |
registerSQLFragmentFactory(SQLFragmentFactory fac)
Register plugin SQLFragmentFactory to create SQLFragments from the given String if not recognized by the base implementation.
|
boolean |
removeFromObject(FromObject obj)
Removes the given FromObject from the SQLQuery.
|
boolean |
removeGroupByColumn(SQLFragment 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.
|
protected boolean |
removeWhereObject(SQLFragment obj)
Removes a top level WhereObject from the WHERE clause.
|
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.
|
protected void |
replaceWithAliases(FromObject[] froms)
replace any From Objects in the list that are aliases for a subquery_factoring_clause
|
void |
setExtraObjects(java.util.Collection<? extends SystemObject> objs) |
void |
setGroupByObject(GroupByObject obj)
Sets the group by object.
|
void |
setHavingObject(WhereObject having)
Sets the HAVING clause of the query.
|
void |
setHierarchicalQueryObject(HierarchicalQueryObject obj)
Sets the CONNECT BY clause of the query.
|
protected void |
setNewFromObject(DBObject frag, FromObject oldFrom, FromObject newFrom) |
void |
setOrderByObjects(OrderByObject[] orderbys)
Sets the order by objects for the query.
|
void |
setSingleRelation(Relation singleRelation) |
protected void |
setSQLQuery(SQLQuery query)
Sets the query we are building.
|
protected void |
setViewColDataType(Column col, SelectObject so) |
void |
setWhereObject(WhereObject obj)
Sets the WhereObject on the query (whilst caching any appropriate dependencies).
|
void |
syncViewColumns()
Deprecated.
- no longer required
|
<T extends SQLQueryException> |
throwException(T sqe)
Method that takes a SQLQueryException and rethrows it unless it is a SQLQueryClauseException and we are in the middle of a build.
|
protected void |
unloadObject(DBObject frag) |
protected void |
validateAlias(AliasFragment frag, java.lang.String type, java.lang.String alias) |
void |
validateQuery()
Validates a query object to check that its internal structure is correct.
|
canBuildComponents, createObject, registerObjectbuildObject, buildObjectComponent, canBuildEditableObject, ensureComponent, fillInObject, fillInObjectComponent, findObjectInProviderCache, findObjectInProviderCache, getBuiltProperties, getDerivedProperties, getObjectType, getProvider, getSchema, isBuildableProperty, markAsBuilt, markAsBuilt, needsBuilding, needsBuilding, newObject, newObject, updateTimestamp, updateTimestampclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddSetOperatorObject, ensureQueryNonDeclarative, getBuiltInFunctions, matchesProvider, parseOnExpression, supportsConnectBy, supportsGroupBy, supportsOrderByprotected static final SQLFragment[] EMPTY_ARRAY
protected AbstractSQLQueryBuilder(DBObjectProvider pro, Schema defaultSchema)
protected final java.util.logging.Logger getLogger()
getLogger in class AbstractDBObjectBuilder<SQLQuery>protected final Schema getDefaultSchema()
protected final SQLQuery getQuery()
public final void buildQuery(java.lang.String sql)
throws SQLQueryException
buildQuery in interface SQLQueryBuilderSQLQueryException - if the query cannot be built.
public final void buildQuery(java.lang.String sql,
SQLQueryOwner parent)
throws SQLQueryException
buildQuery in interface SQLQueryBuilderSQLQueryException - if the query cannot be built.protected final void setSQLQuery(SQLQuery query)
protected abstract void buildQueryImpl(java.lang.String sql,
SQLQuery query,
SQLQueryOwner parent)
throws SQLQueryException
sql - the query string to buildquery - the SQLQuery object to build the declarative representation in toparent - the query's owner (if one exists)SQLQueryException - if the query cannot be built.public java.util.Collection<java.lang.String> clearDerivedProperties(SQLQuery obj, java.lang.String property, DBObjectChange change)
DerivedPropertyBuilderclearDerivedProperties in class DerivedPropertyBuilder<SQLQuery>obj - the object the property is being changed onproperty - the property being changedchange - the overall change that is occuringpublic final void buildQuery(SQLQuery query) throws SQLQueryException
SQLQueryBuilderbuildQuery in interface SQLQueryBuilderSQLQueryException - if the query cannot be built.public final void buildDeclarativeProperties(SQLQuery query) throws SQLQueryException
query - the query to build (cannot be null)SQLQueryExceptionpublic <T extends SQLQueryException> void throwException(T sqe) throws T extends SQLQueryException
T - SQLQueryException implementationsqe - exception to cache or rethrowT - if sqe is not a clause exception (or we're not building)T extends SQLQueryExceptionpublic void addClauseException(SQLQueryClauseException sce)
sce - the problem with a clause in the query we're building.java.lang.IllegalStateException - if this method is called and we're not building a query.
public void validateQuery()
throws SQLQueryException
SQLQueryBuildervalidateQuery in interface SQLQueryBuilderSQLQueryException - if the query fails to validate.protected void ensureIDs(SQLFragment... frags)
ensureID(DBObject)public DBObjectID ensureID(DBObject frag)
protected void loadObjects(DBObject[] frags)
protected void loadObject(DBObject frag)
protected void unloadObject(DBObject frag)
protected java.util.List<DBObjectID> getIDs(DBObject[] objs) throws SQLQueryException
SQLQueryExceptionprotected java.util.Map<DBObjectID,FromObject> getRelIDs(FromObject[] usagesToUse)
protected void setNewFromObject(DBObject frag, FromObject oldFrom, FromObject newFrom)
protected java.lang.String getInternalName(java.lang.String name)
protected java.lang.String getExternalName(java.lang.String name)
protected boolean isValidName(java.lang.String type,
java.lang.String name)
protected void validateAlias(AliasFragment frag, java.lang.String type, java.lang.String alias) throws InvalidAliasException
InvalidAliasExceptionpublic SQLQuery getSQLQuery()
SQLQueryBuildergetSQLQuery in interface SQLQueryBuilderpublic void addSelectObject(SelectObject select) throws SQLQueryException
SQLQueryBuilderaddSelectObject in interface SQLQueryBuilderSQLQueryException
public void addSelectObject(int index,
SelectObject select)
throws SQLQueryException
SQLQueryBuilderaddSelectObject in interface SQLQueryBuilderSQLQueryExceptionpublic boolean isUniqueSelectAlias(java.lang.String alias)
SQLQueryBuilderisUniqueSelectAlias in interface SQLQueryBuilder
protected boolean isUniqueSelectAlias(java.lang.String alias,
java.util.List<java.lang.String> extraNames)
public java.lang.String createUniqueSelectAlias(java.lang.String base)
SQLQueryBuildercreateUniqueSelectAlias in interface SQLQueryBuilder
protected java.lang.String createUniqueSelectAlias(java.lang.String base,
java.util.List<java.lang.String> extraNames)
public SelectObject getSelectObject(java.lang.String usableAlias)
SQLQueryBuildergetSelectObject in interface SQLQueryBuilderpublic SelectObject constructSelectObject(java.lang.String expression, java.lang.String alias) throws SQLQueryException
SQLQueryBuilderconstructSelectObject in interface SQLQueryBuilderexpression - the sql for the SelectObjectalias - the alias for the SelectObjectSQLQueryExceptionpublic SQLQueryBuilder.SQLQueryObjectSet constructSelectObject(Column col, FromObject usageToUse) throws SQLQueryException
SQLQueryBuilderconstructSelectObject in interface SQLQueryBuildercol - 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.public SQLQueryBuilder.SQLQueryObjectSet constructSelectObjects(Column[] baseCols, FromObject[] usagesToUse) throws SQLQueryException
SQLQueryBuilderconstructSelectObjects in interface SQLQueryBuilderbaseCols - 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.protected SelectObject doConstructSelectObject(Column col, java.util.Map<DBObjectID,FromObject> relsToUse, java.util.Map<DBObjectID,FromObject> newRels, java.util.List<java.lang.String> relNames, java.util.List<java.lang.String> colNames) throws SQLQueryException
SQLQueryExceptionprotected SelectObject createSelectObject(DBObjectID colId, FromObject from, java.lang.String alias)
protected void addSelectObjects(SelectObject[] selects)
public boolean removeSelectObject(SelectObject obj)
SQLQueryBuilderremoveSelectObject in interface SQLQueryBuilderobj - the SelectObject to remove.public void replaceSelectObject(SelectObject oldSelect, SelectObject newSelect) throws SQLQueryException
SQLQueryBuilderreplaceSelectObject in interface SQLQueryBuilderSQLQueryExceptionpublic boolean isUniqueFromAlias(java.lang.String alias)
SQLQueryBuilderisUniqueFromAlias in interface SQLQueryBuilder
protected boolean isUniqueFromAlias(java.lang.String alias,
java.util.List<java.lang.String> extraNames)
public java.lang.String createUniqueFromAlias(java.lang.String base)
SQLQueryBuildercreateUniqueFromAlias in interface SQLQueryBuilder
protected java.lang.String createUniqueFromAlias(java.lang.String base,
java.util.List<java.lang.String> extraNames)
public FromObject[] listAllFromObjects()
SQLQueryBuilderlistAllFromObjects in interface SQLQueryBuilderpublic FromObject[] listAllFromObjects(boolean includeJoins)
SQLQueryBuilderlistAllFromObjects in interface SQLQueryBuilderincludeJoins - if set to true, FromObjects for JOINs will be included in the returned arraypublic FromObject getFromObject(java.lang.String usableAlias)
SQLQueryBuildergetFromObject in interface SQLQueryBuilderpublic FromObject getFromObject(java.lang.String usableAlias, FromObject extrafrom)
public FromObject constructFromObject(java.lang.String expression, java.lang.String alias) throws SQLQueryException
SQLQueryBuilderconstructFromObject in interface SQLQueryBuilderexpression - the sql for the FromObjectalias - the alias for the FromObjectSQLQueryExceptionprotected FromObject createFromObject(SchemaObject rel, java.util.List<java.lang.String> extraNames) throws SQLQueryException
SQLQueryExceptionpublic SQLQueryBuilder.SQLQueryObjectSet constructFromObject(SchemaObject relation, boolean createSelectObjects, boolean createJoins, FromObject[] includeInJoins) throws SQLQueryException
SQLQueryBuilderconstructFromObject in interface SQLQueryBuilderrelation - a table, view or synonym 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.protected FromObject doConstructFromObject(SchemaObject relation, java.util.List<DBObjectID> baseRelIDs, java.util.List<java.lang.String> relNames, java.util.Map<DBObjectID,FromObject> newRels, java.util.List<Column> cols, java.util.List<FKConstraint> fks) throws SQLQueryException
SQLQueryExceptionpublic SQLQueryBuilder.SQLQueryObjectSet constructFromObjects(Relation[] baseRelations, boolean createSelectObjects, boolean createJoins, FromObject[] includeInJoins) throws SQLQueryException
SQLQueryBuilderconstructFromObjects in interface SQLQueryBuilderbaseRelations - 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.public void addFromObject(FromObject from) throws SQLQueryException
SQLQueryBuilderaddFromObject in interface SQLQueryBuilderSQLQueryExceptionprotected void addFromObjects(FromObject[] froms)
protected void addJoinObject(FromObject from)
public void replaceFromObject(FromObject oldFrom, FromObject newFrom) throws SQLQueryException
SQLQueryBuilderreplaceFromObject in interface SQLQueryBuilderSQLQueryExceptionpublic boolean removeJoinObject(FromObject obj)
SQLQueryBuilderremoveJoinObject in interface SQLQueryBuilderpublic boolean removeFromObject(FromObject obj)
SQLQueryBuilderremoveFromObject in interface SQLQueryBuilderobj - the FromObject to remove.public SQLQueryBuilder.SQLQueryObjectSet constructFKJoin(FKConstraint fk, FromObject left, FromObject right) throws SQLQueryException
SQLQueryBuilderconstructFKJoin in interface SQLQueryBuilderfk - 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.SQLQueryExceptionpublic SQLQueryBuilder.SQLQueryObjectSet constructFKJoins(FKConstraint[] fks, FromObject[] usagesToUse) throws SQLQueryException
SQLQueryBuilderconstructFKJoins in interface SQLQueryBuilderfks - 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 necessarySQLQueryExceptionprotected FromObject doConstructJoin(FKConstraint fk, java.util.Map<DBObjectID,FromObject> relsIDsToUse, java.util.List<FromObject> newFroms, FromObject left, FromObject right) throws SQLQueryException
SQLQueryExceptionpublic FromObject createJoinObject(FKConstraint fk, FromObject left, FromObject right) throws SQLQueryException
SQLQueryBuildercreateJoinObject in interface SQLQueryBuilderfk - the FKConstraint to use to create the join conditionleft - the from for the LHS of the joinright - the from for the RHS of the joinSQLQueryExceptionprotected JoinCondition createJoinCondition(FKConstraint fk, JoinObject join)
protected FKUsage doConstructFKUsage(FKConstraint fk, java.util.Map relsIDsToUse, java.util.List<FromObject> newFroms) throws SQLQueryException
SQLQueryExceptionprotected FKUsage createFKUsage(DBObjectID fkID, FromObject left, FromObject right)
public void setWhereObject(WhereObject obj)
SQLQueryBuildersetWhereObject in interface SQLQueryBuilderobj - the query's new WhereObjectprotected boolean removeWhereObject(SQLFragment obj)
public RelationUsage[] getRelationUsages()
SQLQueryBuilderDBUtil.findChildren( builder.getSQLQuery(), RelationUsage.class )
getRelationUsages in interface SQLQueryBuilderDBUtil.findChildren(oracle.javatools.db.DBObject, java.lang.Class<T>)public SQLFragment[] getDependentObjects(FromObject from)
getDependentObjects in interface SQLQueryBuilderfrom - the FromObject to get the dependencies forpublic SQLFragment[] getDependentObjects(SelectObject select)
getDependentObjects in interface SQLQueryBuilderselect - the object to get the dependencies forpublic boolean canMergeRelationUsages(RelationUsage baseUsage, RelationUsage mergingUsage)
SQLQueryBuildercanMergeRelationUsages in interface SQLQueryBuilderbaseUsage - 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.public void mergeRelationUsages(RelationUsage baseUsage, RelationUsage mergingUsage) throws SQLQueryException
SQLQueryBuildermergeRelationUsages in interface SQLQueryBuilderbaseUsage - 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.public FKUsage[] listAvailableFKs()
SQLQueryBuilderlistAvailableFKs in interface SQLQueryBuilder@Deprecated public ColumnUsage[] getColumnUsages()
getColumnUsages in interface SQLQueryBuilderDBUtil.findChildren(oracle.javatools.db.DBObject, java.lang.Class<T>)public FromObjectUsage findColumnInFromObjects(java.lang.String colName, boolean external, SQLFragment creating, FromObject... extraFroms) throws SQLQueryException
colName - the column name to findexternal - whether colName is an external (true) or internal (false) name.creating - the fragment we are in the context of creatingextraFroms - extra FromObjects to search within for the column (the query's own FromObjects are searched automatically).SQLQueryExceptionprotected void replaceWithAliases(FromObject[] froms)
protected FromObjectUsage findColumnInFromObjects(java.lang.String colName, boolean external, FromObject[] froms, boolean allowDuplicates, boolean enforceInAll, SQLFragment creating) throws SQLQueryException
colName - the name of the column to findexternal - whether colName is an external (true) or internal (false) name.froms - the FromObjects to search inallowDuplicates - whether to allow duplicate columns to exist ( if false a found duplicate will throw a SQLQueryException)enforceInAll - whether to enforce that the column must exist in all FromObjects (e.g. when creating a join), if true and the column isn't present in all FROMs a SQLQueryException will be thrown.creating - the fragment we are in the context of creatingSQLQueryExceptionpublic FromObjectUsage findColumnInFromExpression(java.lang.String colName, boolean external, SQLFragment exp, boolean allowDuplicates, FromObject from, SQLFragment creating) throws SQLQueryException
colName - the name of the column to findexternal - whether colName is an external (true) or internal (false) name.exp - the expression to search under (e.g. if this is a RelationUsage we look for a Column on the referenced Relation).allowDuplicates - whether to allow duplicate columns to exist ( if false a found duplicate will throw a SQLQueryException)from - the parent of expcreating - the fragment we are in the context of creatingSQLQueryExceptionprotected FromObjectUsage findColumnInColumnUsage(java.lang.String colName, boolean external, ColumnUsage colu, FromObject from)
colName - the name of the column to findexternal - whether colName is an external (true) or internal (false) name.colu - the ColumnUsage to search underfrom - the parent of coluprotected FromObjectUsage findColumnInJoin(java.lang.String colName, boolean external, JoinObject join, boolean allowDuplicates, SQLFragment creating) throws SQLQueryException
colName - the name of the column to findexternal - whether colName is an external (true) or internal (false) name.join - the JoinObject to search underneathallowDuplicates - whether to allow duplicate columns to exist ( if false a found duplicate will throw a SQLQueryException)creating - the fragment we are in the context of creatingSQLQueryExceptionpublic FromObjectUsage findColumnInRelation(java.lang.String colName, boolean external, RelationUsage relU) throws SQLQueryException
colName - the name of the column to findexternal - whether colName is an external (true) or internal (false) name.relU - the relation usage that references the relation to search.SQLQueryExceptionpublic FromObjectUsage findColumnInRelation(java.lang.String colName, boolean external, Relation rel) throws SQLQueryException
Warning: The returned ColumnUsage won't have a FromObject set.
colName - the name of the column to findexternal - whether colName is an external (true) or internal (false) name.rel - the relation to search inSQLQueryExceptionpublic SelectObjectUsage findColumnInSubQuery(java.lang.String colName, boolean external, SQLQuery query) throws SQLQueryException
SQLQueryExceptionpublic ColumnUsage findColumnInStarSubQuery(java.lang.String colName, boolean external, FromObject from) throws SQLQueryException
SQLQueryExceptionpublic void setHierarchicalQueryObject(HierarchicalQueryObject obj)
SQLQueryBuildersetHierarchicalQueryObject in interface SQLQueryBuilderpublic void setGroupByObject(GroupByObject obj)
SQLQueryBuildersetGroupByObject in interface SQLQueryBuilderpublic boolean canSetGroupBy()
SQLQueryBuildercanSetGroupBy in interface SQLQueryBuilderpublic void addGroupByColumn(SQLFragment colu)
SQLQueryBuilderaddGroupByColumn in interface SQLQueryBuilder
public void addGroupByColumn(int index,
SQLFragment colu)
SQLQueryBuilderaddGroupByColumn in interface SQLQueryBuilderpublic boolean removeGroupByColumn(SQLFragment colu)
SQLQueryBuilderremoveGroupByColumn in interface SQLQueryBuilderpublic SQLFragment parseHavingExpression(java.lang.String expression) throws SQLQueryException
parseHavingExpression in interface SQLQueryBuilderexpression - the sql to parse as a HAVING fragment.SQLQueryExceptionpublic final SQLFragment parseOrderByExpression(java.lang.String expression) throws SQLQueryException
SQLQueryBuilderparseOrderByExpression in interface SQLQueryBuilderexpression - the sql to parse as a ORDER BY fragment.SQLQueryExceptionprotected SQLFragment parseOrderByExpression(java.lang.String expression, OrderByObject obo) throws SQLQueryException
SQLQueryExceptionpublic void setHavingObject(WhereObject having)
SQLQueryBuildersetHavingObject in interface SQLQueryBuilderpublic void addOrderByObject(OrderByObject ob)
SQLQueryBuilderaddOrderByObject in interface SQLQueryBuilder
public void addOrderByObject(int index,
OrderByObject ob)
SQLQueryBuilderaddOrderByObject in interface SQLQueryBuilderpublic boolean removeOrderByObject(OrderByObject ob)
SQLQueryBuilderremoveOrderByObject in interface SQLQueryBuilderpublic void replaceOrderByObject(OrderByObject oldOb, OrderByObject newOb)
SQLQueryBuilderreplaceOrderByObject in interface SQLQueryBuilderpublic void setOrderByObjects(OrderByObject[] orderbys)
SQLQueryBuildersetOrderByObjects in interface SQLQueryBuilder
@Deprecated
public void syncViewColumns()
throws AliasInUseException
syncViewColumns in interface SQLQueryBuilderAliasInUseExceptionpublic java.lang.String getColumnName(SelectObject sel)
public void checkUsageQualifications()
public final SQLFragment parseFromExpression(java.lang.String expression) throws SQLQueryException
SQLQueryBuilderparseFromExpression in interface SQLQueryBuilderexpression - the sql to parse as a FROM fragment.SQLQueryExceptionprotected SQLFragment parseFromExpression(java.lang.String expression, FromObject creating) throws SQLQueryException
SQLQueryExceptionpublic final SQLFragment parseSelectExpression(java.lang.String expression) throws SQLQueryException
SQLQueryBuilderparseSelectExpression in interface SQLQueryBuilderexpression - the sql to parse as a SELECT fragment.SQLQueryExceptionprotected SQLFragment parseSelectExpression(java.lang.String expression, SelectObject creating) throws SQLQueryException
SQLQueryExceptionpublic final SQLFragment parseWhereExpression(java.lang.String expression) throws SQLQueryException
SQLQueryBuilderparseWhereExpression in interface SQLQueryBuilderexpression - the sql to parse as a WHERE fragment.SQLQueryExceptionpublic SQLFragment parseWhereExpression(java.lang.String expression, WhereObject creating) throws SQLQueryException
SQLQueryExceptionpublic Column[] getColumns() throws DBException
SQLQueryBuildergetColumns in interface SQLQueryBuilderDBException - if the query cannot be processedprotected abstract DerivedPropertyBuilder getDTUBuilder(int columnIndex)
protected abstract boolean containsAsterisk()
throws SQLQueryException
SQLQueryExceptionpublic abstract java.util.List<AbstractSQLQueryBuilder.QueryColumnInfo> getQueryColumnInfos() throws SQLQueryException
SQLQueryExceptionprotected void setViewColDataType(Column col, SelectObject so)
public void setSingleRelation(Relation singleRelation)
public void setExtraObjects(java.util.Collection<? extends SystemObject> objs)
protected void addExtraObject(SystemObject obj)
protected SchemaObject getObject(java.lang.String type, Schema sch, java.lang.String relation) throws DBException
DBExceptionprotected SchemaObject getObject(DBObjectCriteria crit) throws DBException
DBExceptionpublic void registerSQLFragmentFactory(SQLFragmentFactory fac)
SQLQueryBuilderregisterSQLFragmentFactory in interface SQLQueryBuilderprotected void registerAllSQLFragmentFactories(AbstractSQLQueryBuilder builder)
public final SQLFragment createFromFactory(SQLFragment parent, java.lang.String clause, java.lang.Integer offset)