public class SQLStatement extends Object
SELECT {expr}, {expr}, ... FROM {tblExpr} [joinInfo {tblExpr} ON ...] ... WHERE {boolExpr} [AND|OR] {boolExpr} ... GROUP BY {expr}, {expr} HAVING {boolExpr} ORDER BY {expr} [ASC|DESC], {expr} [ASC|DESC], ...and also supports UNIONs between SQLStatements, and having sub-queries of other SQLStatements. Alternatively, for an UPDATE,
UPDATE {tbl} SET {expr}={val}, {expr}={val}, ... WHERE {boolExpr} [AND|OR] {boolExpr} ...
The generated SQL is cached. Any use of a mutating method, changing the composition of the statement will clear the cached SQL, and it will be regenerated when
getStatementis called next.
Modifier and Type | Class and Description |
---|---|
protected class |
SQLStatement.SelectedItem |
Modifier and Type | Field and Description |
---|---|
protected boolean |
aggregated
whether there is an aggregate expression present in the select
|
protected String |
candidateClassName
Name of class that this statement selects (optional, only typically for unioned statements).
|
protected org.datanucleus.ClassLoaderResolver |
clr
ClassLoader resolver to use.
|
protected boolean |
distinct
Whether the statement is distinct.
|
static String |
EXTENSION_SQL_TABLE_NAMING_STRATEGY |
protected Map<String,Object> |
extensions
Map of extensions for use in generating the SQL, keyed by the extension name.
|
protected List<SQLExpression> |
groupingExpressions
Expression(s) for the GROUP BY clause.
|
protected BooleanExpression |
having
Having clause.
|
protected List<SQLJoin> |
joins
List of joins for this statement.
|
protected SQLTableNamer |
namer |
protected boolean[] |
orderingDirections
Directions for any ORDER BY expressions (1 for each orderingExpressions entry).
|
protected SQLExpression[] |
orderingExpressions
Expressions for any ORDER BY clause.
|
protected org.datanucleus.query.NullOrderingType[] |
orderNullDirectives
Directives for null handling of any ORDER BY expressions (1 for each orderingExpressions entry).
|
protected SQLStatement |
parent
Parent statement, if this is a subquery.
|
protected SQLTable |
primaryTable
Primary table for this statement.
|
protected QueryGenerator |
queryGenerator
Context of any query generation.
|
protected long |
rangeCount
The number of records to be retrieved in any range restriction.
|
protected long |
rangeOffset
The offset for any range restriction.
|
protected RDBMSStoreManager |
rdbmsMgr
Manager for the RDBMS datastore.
|
protected boolean |
requiresJoinReorder |
protected List<SQLStatement.SelectedItem> |
selectedItems
List of select objects.
|
protected SQLText |
sql
Cached SQL statement, generated by getStatement().
|
protected Map<String,SQLTableGroup> |
tableGroups
Map of table groups keyed by the group name.
|
protected static Map<String,SQLTableNamer> |
tableNamerByName
Map of SQLTable naming instance keyed by the name of the naming scheme.
|
protected Map<String,SQLTable> |
tables
Map of tables referenced in this statement, keyed by their alias.
|
protected List<SQLStatement> |
unions
List of unioned SQLStatements (if any).
|
protected SQLExpression[] |
updates
Array of update expressions when the statement is an UPDATE.
|
protected BooleanExpression |
where
Where clause.
|
Constructor and Description |
---|
SQLStatement(RDBMSStoreManager rdbmsMgr,
Table table,
DatastoreIdentifier alias,
String tableGroupName)
Constructor for an SQL statement.
|
SQLStatement(RDBMSStoreManager rdbmsMgr,
Table table,
DatastoreIdentifier alias,
String tableGroupName,
Map<String,Object> extensions)
Constructor for an SQL statement.
|
SQLStatement(SQLStatement parentStmt,
RDBMSStoreManager rdbmsMgr,
Table table,
DatastoreIdentifier alias,
String tableGroupName)
Constructor for an SQL statement that is a subquery of another statement.
|
SQLStatement(SQLStatement parentStmt,
RDBMSStoreManager rdbmsMgr,
Table table,
DatastoreIdentifier alias,
String tableGroupName,
Map<String,Object> extensions)
Constructor for an SQL statement that is a subquery of another statement.
|
Modifier and Type | Method and Description |
---|---|
void |
addExtension(String key,
Object value)
Method to define an extension for this query statement allowing control over its behaviour in generating a query.
|
void |
addGroupingExpression(SQLExpression expr)
Method to add a grouping expression to the query.
|
protected void |
addJoin(SQLJoin.JoinType joinType,
SQLTable sourceTable,
JavaTypeMapping sourceMapping,
JavaTypeMapping sourceParentMapping,
SQLTable targetTable,
JavaTypeMapping targetMapping,
JavaTypeMapping targetParentMapping,
Object[] discrimValues)
Internal method to form a join to the specified table using the provided mappings.
|
protected void |
addOrderComponent(SQLText orderST,
String orderString,
SQLExpression orderExpr,
boolean orderDirection,
org.datanucleus.query.NullOrderingType orderNullDirective,
DatastoreAdapter dba) |
protected void |
addOrderingColumnsToSelect()
Convenience method to add any necessary columns to the SELECT that are needed
by the ordering constraint.
|
boolean |
allUnionsForSamePrimaryTable()
Convenience accessor for whether all unions of this statement are for the same primary table.
|
SQLTable |
crossJoin(Table target,
String targetAlias,
String tableGrpName)
Method to form a right outer join to the specified table using the provided mappings.
|
protected SQLText |
generateOrderingStatement()
Convenience method to generate the ordering statement to add to the overall query statement.
|
String |
getCandidateClassName() |
org.datanucleus.ClassLoaderResolver |
getClassLoaderResolver() |
DatastoreAdapter |
getDatastoreAdapter() |
SQLText |
getDeleteStatement()
Accessor for the SQL DELETE statement.
|
protected BooleanExpression |
getJoinConditionForJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
JavaTypeMapping sourceParentMapping,
SQLTable targetTable,
JavaTypeMapping targetMapping,
JavaTypeMapping targetParentMapping,
Object[] discrimValues)
Convenience method to generate the join condition between source and target tables for the supplied
mappings.
|
SQLJoin |
getJoinForTable(SQLTable sqlTbl)
Accessor for the type of join used for the specified table.
|
SQLJoin.JoinType |
getJoinTypeForTable(SQLTable sqlTbl)
Accessor for the type of join used for the specified table.
|
int |
getNumberOfSelects()
Accessor for the number of selected items in the SELECT clause.
|
int |
getNumberOfTableGroups()
Accessor for the number of table groups.
|
int |
getNumberOfTables()
Accessor for the number of tables defined for this statement.
|
int |
getNumberOfUnions() |
SQLStatement |
getParentStatement() |
SQLTable |
getPrimaryTable()
Accessor for the primary table of the statement.
|
QueryGenerator |
getQueryGenerator() |
RDBMSStoreManager |
getRDBMSManager() |
SQLText |
getSelectStatement()
Accessor for the SQL SELECT statement.
|
SQLExpressionFactory |
getSQLExpressionFactory() |
SQLTable |
getTable(String alias)
Accessor for the SQLTable object with the specified alias (if defined for this statement).
|
SQLTable |
getTable(Table table,
String groupName)
Accessor for the SQLTable object for the specified table (if defined for this statement)
in the specified table group.
|
SQLTable |
getTableForDatastoreContainer(Table table)
Convenience method to find a registered SQLTable that is for the specified table
|
SQLTableGroup |
getTableGroup(String groupName)
Accessor for the table group with this name.
|
protected SQLTableNamer |
getTableNamer(String namingSchema)
Method to return the namer for a particular schema.
|
List<SQLStatement> |
getUnions()
Accessor for the unioned statements.
|
SQLText |
getUpdateStatement()
Accessor for the SQL UPDATE statement.
|
Object |
getValueForExtension(String key)
Accessor for the value for an extension.
|
boolean |
hasUpdates() |
SQLTable |
innerJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
JavaTypeMapping sourceParentMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
JavaTypeMapping targetParentMapping,
Object[] discrimValues,
String tableGrpName)
Method to form an inner join to the specified table using the provided mappings.
|
SQLTable |
innerJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
Object[] discrimValues,
String tableGrpName)
Method to form an inner join to the specified table using the provided mappings.
|
protected void |
invalidateStatement()
Method to uncache the generated SQL (because some condition has changed).
|
boolean |
isChildStatementOf(SQLStatement stmt)
Convenience method to return if this statement is a child (inner) statement of the supplied
statement.
|
boolean |
isDistinct()
Accessor for whether the statement restricts the results to distinct.
|
SQLTable |
join(SQLJoin.JoinType joinType,
SQLTable sourceTable,
JavaTypeMapping sourceMapping,
JavaTypeMapping sourceParentMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
JavaTypeMapping targetParentMapping,
Object[] discrimValues,
String tableGrpName,
boolean applyToUnions)
Method to form a join to the specified table using the provided mappings.
|
SQLTable |
join(SQLJoin.JoinType joinType,
SQLTable sourceTable,
JavaTypeMapping sourceMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
Object[] discrimValues,
String tableGrpName)
Method to form a join to the specified table using the provided mappings, with the join also being applied to any UNIONed statements.
|
SQLTable |
join(SQLJoin.JoinType joinType,
SQLTable sourceTable,
JavaTypeMapping sourceMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
Object[] discrimValues,
String tableGrpName,
boolean applyToUnions)
Method to form a join to the specified table using the provided mappings.
|
SQLTable |
leftOuterJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
JavaTypeMapping sourceParentMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
JavaTypeMapping targetParentMapping,
Object[] discrimValues,
String tableGrpName)
Method to form a left outer join to the specified table using the provided mappings.
|
SQLTable |
leftOuterJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
Object[] discrimValues,
String tableGrpName)
Method to form a left outer join to the specified table using the provided mappings.
|
void |
log(org.datanucleus.util.NucleusLogger logger)
Method to dump the statement to the supplied log (debug level).
|
String |
removeCrossJoin(SQLTable targetSqlTbl)
Method to remove a cross join for the specified table (if joined via cross join).
|
SQLTable |
rightOuterJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
JavaTypeMapping sourceParentMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
JavaTypeMapping targetParentMapping,
Object[] discrimValues,
String tableGrpName)
Method to form a right outer join to the specified table using the provided mappings.
|
SQLTable |
rightOuterJoin(SQLTable sourceTable,
JavaTypeMapping sourceMapping,
Table target,
String targetAlias,
JavaTypeMapping targetMapping,
Object[] discrimValues,
String tableGrpName)
Method to form a right outer join to the specified table using the provided mappings.
|
int[] |
select(SQLExpression expr,
String alias)
Select an expression.
|
int |
select(SQLTable table,
Column column,
String alias)
Add a select clause for the specified column.
|
int[] |
select(SQLTable table,
JavaTypeMapping mapping,
String alias)
Add a select clause for the specified field (via its mapping) and apply to unions.
|
int[] |
select(SQLTable table,
JavaTypeMapping mapping,
String alias,
boolean applyToUnions)
Add a select clause for the specified field (via its mapping).
|
void |
setCandidateClassName(String name) |
void |
setClassLoaderResolver(org.datanucleus.ClassLoaderResolver clr) |
void |
setDistinct(boolean distinct)
Mutator for whether the query returns distinct results.
|
void |
setHaving(BooleanExpression expr)
Mutator for the "having" expression.
|
void |
setOrdering(SQLExpression[] exprs,
boolean[] descending)
Mutator for the ordering criteria.
|
void |
setOrdering(SQLExpression[] exprs,
boolean[] descending,
org.datanucleus.query.NullOrderingType[] nullOrders)
Mutator for the ordering criteria.
|
void |
setQueryGenerator(QueryGenerator gen) |
void |
setRange(long offset,
long count)
Method to add a range constraint on any SELECT.
|
void |
setUpdates(SQLExpression[] exprs)
Method to set the UPDATE clause of the statement.
|
void |
union(SQLStatement stmt)
Method to union this SQL statement with another SQL statement.
|
void |
whereAnd(BooleanExpression expr,
boolean applyToUnions)
Method to add an AND condition to the WHERE clause.
|
void |
whereOr(BooleanExpression expr,
boolean applyToUnions)
Method to add an OR condition to the WHERE clause.
|
public static final String EXTENSION_SQL_TABLE_NAMING_STRATEGY
protected static final Map<String,SQLTableNamer> tableNamerByName
protected SQLText sql
protected RDBMSStoreManager rdbmsMgr
protected org.datanucleus.ClassLoaderResolver clr
protected QueryGenerator queryGenerator
protected SQLTableNamer namer
protected String candidateClassName
protected boolean distinct
protected Map<String,Object> extensions
protected SQLStatement parent
protected List<SQLStatement> unions
protected List<SQLStatement.SelectedItem> selectedItems
protected SQLExpression[] updates
protected boolean aggregated
protected SQLTable primaryTable
protected boolean requiresJoinReorder
protected Map<String,SQLTable> tables
protected Map<String,SQLTableGroup> tableGroups
protected BooleanExpression where
protected List<SQLExpression> groupingExpressions
protected BooleanExpression having
protected SQLExpression[] orderingExpressions
protected boolean[] orderingDirections
protected org.datanucleus.query.NullOrderingType[] orderNullDirectives
protected long rangeOffset
protected long rangeCount
public SQLStatement(RDBMSStoreManager rdbmsMgr, Table table, DatastoreIdentifier alias, String tableGroupName)
rdbmsMgr
- The datastore managertable
- The primary tablealias
- Alias for this tabletableGroupName
- Name of candidate table-group (if any). Uses "Group0" if not providedpublic SQLStatement(RDBMSStoreManager rdbmsMgr, Table table, DatastoreIdentifier alias, String tableGroupName, Map<String,Object> extensions)
rdbmsMgr
- The datastore managertable
- The primary tablealias
- Alias for this tabletableGroupName
- Name of candidate table-group (if any). Uses "Group0" if not providedextensions
- Optional extensionspublic SQLStatement(SQLStatement parentStmt, RDBMSStoreManager rdbmsMgr, Table table, DatastoreIdentifier alias, String tableGroupName)
parentStmt
- Parent statementrdbmsMgr
- The datastore managertable
- The primary tablealias
- Alias for this tabletableGroupName
- Name of candidate table-group (if any). Uses "Group0" if not providedpublic SQLStatement(SQLStatement parentStmt, RDBMSStoreManager rdbmsMgr, Table table, DatastoreIdentifier alias, String tableGroupName, Map<String,Object> extensions)
parentStmt
- Parent statementrdbmsMgr
- The datastore managertable
- The primary tablealias
- Alias for this tabletableGroupName
- Name of candidate table-group (if any). Uses "Group0" if not providedextensions
- Optional extensionspublic RDBMSStoreManager getRDBMSManager()
public void setClassLoaderResolver(org.datanucleus.ClassLoaderResolver clr)
public org.datanucleus.ClassLoaderResolver getClassLoaderResolver()
public void setCandidateClassName(String name)
public String getCandidateClassName()
public QueryGenerator getQueryGenerator()
public void setQueryGenerator(QueryGenerator gen)
public SQLExpressionFactory getSQLExpressionFactory()
public DatastoreAdapter getDatastoreAdapter()
public SQLStatement getParentStatement()
public boolean isChildStatementOf(SQLStatement stmt)
stmt
- The statement that may be parent, grandparent etc of this statementpublic void addExtension(String key, Object value)
key
- Extension keyvalue
- Value for the keypublic Object getValueForExtension(String key)
key
- Key for the extensionpublic void union(SQLStatement stmt)
stmt
- The other SQL statement to unionpublic int getNumberOfUnions()
public List<SQLStatement> getUnions()
public boolean allUnionsForSamePrimaryTable()
public boolean isDistinct()
public void setDistinct(boolean distinct)
distinct
- Whether to return distinctpublic int getNumberOfSelects()
public int[] select(SQLExpression expr, String alias)
expr
- The expression to add to the select statementalias
- Optional alias for this selected expressionpublic int[] select(SQLTable table, JavaTypeMapping mapping, String alias, boolean applyToUnions)
table
- The SQLTable to select from (null implies the primary table)mapping
- The mapping for the fieldalias
- optional aliasapplyToUnions
- Whether to apply to unionspublic int[] select(SQLTable table, JavaTypeMapping mapping, String alias)
table
- The SQLTable to select from (null implies the primary table)mapping
- The mapping for the fieldalias
- optional aliaspublic int select(SQLTable table, Column column, String alias)
table
- The SQLTable to select from (null implies the primary table)column
- The columnalias
- Optional aliaspublic void setUpdates(SQLExpression[] exprs)
exprs
- The update clause expressionpublic boolean hasUpdates()
public SQLTable getPrimaryTable()
public SQLTable getTable(String alias)
alias
- Aliaspublic SQLTable getTableForDatastoreContainer(Table table)
table
- The tablepublic SQLTable getTable(Table table, String groupName)
table
- The tablegroupName
- Name of the table group where we should look for this tablepublic SQLTableGroup getTableGroup(String groupName)
groupName
- Name of the grouppublic int getNumberOfTableGroups()
public int getNumberOfTables()
public SQLTable join(SQLJoin.JoinType joinType, SQLTable sourceTable, JavaTypeMapping sourceMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, Object[] discrimValues, String tableGrpName)
joinType
- Type of join.sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromtarget
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable join(SQLJoin.JoinType joinType, SQLTable sourceTable, JavaTypeMapping sourceMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, Object[] discrimValues, String tableGrpName, boolean applyToUnions)
joinType
- Type of join.sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromtarget
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)applyToUnions
- Whether to apply to any unioned statementspublic SQLTable join(SQLJoin.JoinType joinType, SQLTable sourceTable, JavaTypeMapping sourceMapping, JavaTypeMapping sourceParentMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, JavaTypeMapping targetParentMapping, Object[] discrimValues, String tableGrpName, boolean applyToUnions)
joinType
- Type of join.sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromsourceParentMapping
- Optional, if this source mapping is a sub mapping (e.g interface impl).target
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)targetParentMapping
- Optional, if this source mapping is a sub mapping (e.g interface impl).discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)applyToUnions
- Whether to apply to any unioned statementspublic SQLTable innerJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, Object[] discrimValues, String tableGrpName)
sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromtarget
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable innerJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, JavaTypeMapping sourceParentMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, JavaTypeMapping targetParentMapping, Object[] discrimValues, String tableGrpName)
sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromsourceParentMapping
- Optional, if this source mapping is a sub mapping (e.g interface impl).target
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)targetParentMapping
- Optional, if this source mapping is a sub mapping (e.g interface impl).discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable leftOuterJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, Object[] discrimValues, String tableGrpName)
sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromtarget
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable leftOuterJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, JavaTypeMapping sourceParentMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, JavaTypeMapping targetParentMapping, Object[] discrimValues, String tableGrpName)
sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromsourceParentMapping
- Optional, if this source mapping is a sub mapping (e.g interface impl).target
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)targetParentMapping
- Optional, if this source mapping is a sub mapping (e.g interface impl).discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable rightOuterJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, Object[] discrimValues, String tableGrpName)
sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromtarget
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)discrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable rightOuterJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, JavaTypeMapping sourceParentMapping, Table target, String targetAlias, JavaTypeMapping targetMapping, JavaTypeMapping targetParentMapping, Object[] discrimValues, String tableGrpName)
sourceTable
- SQLTable for the source (null implies primaryTable)sourceMapping
- Mapping in this table to join fromsourceParentMapping
- mapping for the parent of the sourcetarget
- Table to join totargetAlias
- Alias for the target table (if known)targetMapping
- Mapping in the other table to join to (also defines the table to join to)targetParentMapping
- mapping for the parent of the targetdiscrimValues
- Any discriminator values to apply for the joined table (null if not)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLTable crossJoin(Table target, String targetAlias, String tableGrpName)
target
- Table to join totargetAlias
- Alias for the target table (if known)tableGrpName
- Name of the table group for the target (null implies a new group)public SQLJoin.JoinType getJoinTypeForTable(SQLTable sqlTbl)
sqlTbl
- The table to checkpublic SQLJoin getJoinForTable(SQLTable sqlTbl)
sqlTbl
- The table to checkpublic String removeCrossJoin(SQLTable targetSqlTbl)
targetSqlTbl
- The table to drop the cross join forprotected void addJoin(SQLJoin.JoinType joinType, SQLTable sourceTable, JavaTypeMapping sourceMapping, JavaTypeMapping sourceParentMapping, SQLTable targetTable, JavaTypeMapping targetMapping, JavaTypeMapping targetParentMapping, Object[] discrimValues)
joinType
- Type of join (INNER, LEFT OUTER, RIGHT OUTER, CROSS, NON-ANSI)sourceTable
- SQLTable to join fromsourceMapping
- Mapping in this table to join fromsourceParentMapping
- Optional parent of this source mapping (when joining an impl of an interface)targetTable
- SQLTable to join totargetMapping
- Mapping in the other table to join to (also defines the table to join to)targetParentMapping
- Optional parent of this target mapping (when joining an impl of an interface)discrimValues
- Any discriminator values to apply for the joined table (null if not)protected BooleanExpression getJoinConditionForJoin(SQLTable sourceTable, JavaTypeMapping sourceMapping, JavaTypeMapping sourceParentMapping, SQLTable targetTable, JavaTypeMapping targetMapping, JavaTypeMapping targetParentMapping, Object[] discrimValues)
sourceTable
- Source tablesourceMapping
- Mapping in source tablesourceParentMapping
- Optional parent of this source mapping (if joining an impl of an interface)targetTable
- Target tabletargetMapping
- Mapping in target tabletargetParentMapping
- Optional parent of this target mapping (if joining an impl of an interface)discrimValues
- Optional discriminator values to further restrictprotected SQLTableNamer getTableNamer(String namingSchema)
namingSchema
- Table naming schema to usepublic void whereAnd(BooleanExpression expr, boolean applyToUnions)
expr
- The conditionapplyToUnions
- whether to apply this and to any UNIONs in the statementpublic void whereOr(BooleanExpression expr, boolean applyToUnions)
expr
- The conditionapplyToUnions
- Whether to apply to unionspublic void addGroupingExpression(SQLExpression expr)
expr
- The expressionpublic void setHaving(BooleanExpression expr)
expr
- Boolean expression for the having clausepublic void setOrdering(SQLExpression[] exprs, boolean[] descending)
exprs
- The expressions to order bydescending
- Whether each expression is ascending/descendingpublic void setOrdering(SQLExpression[] exprs, boolean[] descending, org.datanucleus.query.NullOrderingType[] nullOrders)
exprs
- The expressions to order bydescending
- Whether each expression is ascending/descendingnullOrders
- Ordering for nulls (if provided)public void setRange(long offset, long count)
offset
- The offset to start fromcount
- The number of records to returnpublic SQLText getSelectStatement()
public SQLText getUpdateStatement()
public SQLText getDeleteStatement()
DELETE FROM tbl1 A0 WHERE A0.xxx = yyy
If any mutator method has been called since this was last called the SQL will be regenerated
otherwise the SQL is cached.protected SQLText generateOrderingStatement()
protected void addOrderComponent(SQLText orderST, String orderString, SQLExpression orderExpr, boolean orderDirection, org.datanucleus.query.NullOrderingType orderNullDirective, DatastoreAdapter dba)
protected void addOrderingColumnsToSelect()
protected void invalidateStatement()
public void log(org.datanucleus.util.NucleusLogger logger)
logger
- The loggerCopyright © 2017. All rights reserved.