Package org.apache.openjpa.jdbc.sql
Class SelectImpl
java.lang.Object
org.apache.openjpa.jdbc.sql.SelectImpl
- All Implemented Interfaces:
Joins
,Select
,SelectExecutor
Standard
Select
implementation. Usage note: though this class
implements Joins
, it should not be used for joining directly.
Instead, use the return value of newJoins()
.- Author:
- Abe White
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
AResult
implementation wrapped around this select.protected static class
Helper class to track selected columns, with fast contains method. -
Field Summary
Fields inherited from interface org.apache.openjpa.jdbc.sql.Select
EAGER_INNER, EAGER_OUTER, EAGER_PARALLEL, FROM_SELECT_ALIAS, SUBS_ANY_JOINABLE, SUBS_EXACT, SUBS_JOINABLE, SUBS_NONE, TYPE_JOINLESS, TYPE_TWO_PART
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Apply class conditions from relation joins.AND the given joins together.void
Append the given joins to the given buffer.void
Clear odering conditions.void
Clear selected placeholders, and return removed select indexes.void
Clear the existing column selects.Perform a cross join on the given tables.ctx()
Return the JPQL query context of this selecteagerClone
(FieldMapping key, int eagerType, boolean toMany, int sels) Return a select that will be eagerly executed with this one, or null if the select cannot be created for the given key and join type.execute
(JDBCStore store, JDBCFetchConfiguration fetch) Execute this select in the context of the given store manager.execute
(JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel) Execute this select in the context of the given store manager.protected Result
execute
(StoreContext ctx, JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel) Execute this select in the context of the given store manager.executeQuery
(Connection conn, PreparedStatement stmnt, String sql, JDBCStore store, Object[] params, Column[] cols) This method is to provide override for non-JDBC or JDBC-like implementation of executing query.protected ResultSet
executeQuery
(Connection conn, PreparedStatement stmnt, SQLBuffer sql, boolean isLRS, JDBCStore store) This method is to provide override for non-JDBC or JDBC-like implementation of executing query.fullClone
(int sels) Return a SELECT that is a complete clone of this one.boolean
Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.getColumnAlias
(String col, Table table) Return the alias for the given column.getColumnAlias
(String col, Table table, Joins joins) Return the alias for the given column.getColumnAlias
(Column col) Return the alias for the given column.getColumnAlias
(Column col, Object path) Return the alias for the give columngetColumnAlias
(Column col, Joins joins) Return the alias for the given column.Return the select configuration.Return correlated variable nameprotected int
This method is to provide override for non-JDBC or JDBC-like implementation of getting count from the result set.int
Return the number of instances matching this select.getEager
(FieldMapping key) Return the eager select for the given key.Return view of eager selects.getEagerResult
(Connection conn, PreparedStatement stmnt, ResultSet rs, JDBCStore store, JDBCFetchConfiguration fetch, boolean forUpdate, SQLBuffer sql) This method is to provide override for non-JDBC or JDBC-like implementation of executing eager selects.long
The result end index.get joined table metadatas excluded for polymorphic queriesint
The expected result count for the query.Another select instance that creates a temporary table from which this select pulls data.Return the grouping SQL for this select.boolean
Return the flag to indicate whether this Select has internally generated subselectReturn the HAVING clause, or null if none.Get the aliases for identifier columns that can be used in COUNT selects to find the number of matches.get joined table metadatas for polymorphic queriesReturn the top-levelJoin
elements for this select.getJoins()
Return the top-level joins for this select.int
The join syntax for this select, as one of the syntax constants fromJoinSyntaxes
.Return the ordering SQL for this select.Return the parent of this select, if it is a subselect.Return the aliases of all selected columns and all selected buffers, in the order they were selected.Return the actualVal
s andColumn
s that were selected, in the order that they were selected.getSQL()
Get the buffer if it has been computed by a previous call toSelectExecutor.toSelect(boolean, JDBCFetchConfiguration)
, if any.long
The result start index.Return the subselect path for this select, if it is a subselect.Return this select's subselects, or empty collection if none.Return the set of all used table aliases.get table-per-class metadata for polymorphic queriesgetWhere()
Return the WHERE clause, minus any necessary end joins.void
Add a GROUP BY clause.void
Add a GROUP BY clause.void
groupBy
(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch) Group by the columns of the given mapping, possibly including subclasses.void
groupBy
(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) Group by the columns of the given mapping, possibly including subclasses.void
Group by the given column.void
Group by the given columns.void
Group by the given columns.void
Group by the given column.void
Add a GROUP BY clause.void
Add a GROUP BY clause.boolean
hasEagerJoin
(boolean toMany) Whether this select has an eager join of the specified type.boolean
hasJoin
(boolean toMany) Whether this select has a join of the specified type.boolean
Affirm if this receiver requires more than one selects to fetch its data.void
Add the given having conditions.void
Add the given having conditions.void
Add the given having conditions.void
Add the given having conditions.int
indexOf()
The index of this select within the UNION, or 0.void
insertPlaceholder
(String sql, int pos) Insert a placeholder at the given index; use a negative index to count from the back of the select list.boolean
Return true if this is an aggregate select.boolean
isDirty()
boolean
Whether this is a SELECT DISTINCT / UNION ALL.boolean
isEmpty()
Whether we have any joins.boolean
isLob()
Return true if this select includes a LOB.boolean
isLRS()
Whether the result of this select should be treated as a large result set.boolean
isOuter()
Whether this joins path results in outer joins.boolean
isSelected
(Table table) Return whether the given table is being used in this select.join
(ForeignKey fk, boolean inverse, boolean toMany) Join the columns of the given foreign key.int
joinRelation
(String name, ForeignKey fk, ClassMapping target, int subs, boolean inverse, boolean toMany) Join the columns of the given foreign key, which represents a relation via the given field name.org.apache.openjpa.jdbc.sql.JoinSet
joins()
void
Extended trace that logs eager relationsvoid
Move joins that belong to subquery's parentnewJoins()
Return a new instance to use for joining.Return a new instance to use for outer joining.protected SelectImpl.Selects
void
OR the given joins together.boolean
Add an ORDER BY clause.boolean
Add an ORDER BY clause.int
Order by the given columns.int
Order by the given columns.boolean
Order by the given column.boolean
Order by the given column.boolean
Add an ORDER BY clause.boolean
Add an ORDER BY clause.int
orderByPrimaryKey
(ClassMapping mapping, boolean asc, boolean sel) Order on the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.int
orderByPrimaryKey
(ClassMapping mapping, boolean asc, Joins joins, boolean sel) Select and order on the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.int
orderByPrimaryKey
(ClassMapping mapping, boolean asc, Joins joins, boolean sel, boolean aliasOrder) Allow unions to set aliases on order columns.Return a join set making the given joins outer joins.outerJoin
(ForeignKey fk, boolean inverse, boolean toMany) Join the columns of the given foreign key.outerJoinRelation
(String name, ForeignKey fk, ClassMapping target, int subs, boolean inverse, boolean toMany) Join the columns of the given foreign key, which represents a relation via the given field name.path()
prepareStatement
(Connection conn, String sql) This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.protected PreparedStatement
prepareStatement
(Connection conn, SQLBuffer sql, JDBCFetchConfiguration fetch, int rsType, int rsConcur, boolean isLRS) This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.void
removeAlias
(Object key) void
removeTable
(Object key) boolean
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
.boolean
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
.void
select
(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager) Select the columns of the given mapping, possibly including subclasses.void
select
(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager, Joins joins) Select the columns of the given mapping, possibly including subclasses.boolean
Select the given column.int
Select the given columns.int
Select the given columns.boolean
Select the given column.boolean
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
.boolean
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
.void
selectIdentifier
(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager) Select the columns of the given mapping, possibly including subclasses.void
selectIdentifier
(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager, Joins joins) Select the columns of the given mapping, possibly including subclasses.boolean
selectIdentifier
(Column col) Select the given column as one that can be used to get a count of distinct matches.int
selectIdentifier
(Column[] cols) Select the given columns as ones that can be used to get a count of distinct matches.int
selectIdentifier
(Column[] cols, Joins joins) Select the given columns as ones that can be used to get a count of distinct matches.boolean
selectIdentifier
(Column col, Joins joins) Select the given column as one that can be used to get a count of distinct matches.void
selectPlaceholder
(String sql) Select the given SQL as a placeholder for a UNION element.int
selectPrimaryKey
(ClassMapping mapping) Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.int
selectPrimaryKey
(ClassMapping mapping, Joins joins) Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.void
setAggregate
(boolean agg) Set to true for aggregate selects.void
setAutoDistinct
(boolean val) Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.void
setContext
(Context context) Set JPQL query context for this selectSet the correlated variable name being traversed into with the next join.void
setDistinct
(boolean distinct) Whether this is a SELECT DISTINCT / UNION ALL.void
Set joined table metadatas excluded for polymorphic queriesvoid
setExpectedResultCount
(int expectedResultCount, boolean force) The expected result count for the query.void
setFromSelect
(Select sel) Another select instance that creates a temporary table from which this select pulls data.void
setHasSubselect
(boolean hasSub) Set the flag to indicate whether this Select has internally generated subselectsetJoinContext
(Context ctx) Set subquery context when traversing into the next join is in transition from parent context to subquery.void
setJoinedTableClassMeta
(List meta) Set joined table metadatas for polymorphic queriesvoid
setJoinSyntax
(int joinSyntax) The join syntax for this select, as one of the syntax constants fromJoinSyntaxes
.void
setLob
(boolean lob) Set to true for selects that include LOB columns.void
setLRS
(boolean lrs) Whether the result of this select should be treated as a large result set.org.apache.openjpa.jdbc.sql.PathJoins
setOuter
(boolean outer) void
Turn this select into a subselect of the given instance.void
setRange
(long start, long end) Set the result range for this select.void
setSchemaAlias
(String schemaAlias) Record the initial schemaAlias of a join pathsetSubselect
(String alias) Set the subquery alias.void
Set table-per-class metadata for polymorphic queriessetVariable
(String var) Set the variable name being traversed into with the next join.boolean
Whether this select can be executed for update.boolean
supportsRandomAccess
(boolean forUpdate) Return whether this select can support a random access result set type.static String
toOrderAlias
(int index) Helper method to return the proper order alias for the given order column index.toSelect
(boolean forUpdate, JDBCFetchConfiguration fetch) Return this select as a SQL statement formatted for the current dictionary.Return this select as a COUNT SQL statement formatted for the current dictionary.toString()
Implement toString to generate SQL string for profiling/debuggging.void
Add the given where conditions.void
Add the given where conditions.void
Add the given where conditions.void
Add the given where conditions.void
Add the given where conditions.whereClone
(int sels) Return a SELECT with the same joins and where conditions as this one.void
whereForeignKey
(ForeignKey fk, Object oid, ClassMapping mapping, JDBCStore store) Add where conditions setting the given foreign key to the given oid values.void
wherePrimaryKey
(Object oid, ClassMapping mapping, JDBCStore store) Add where conditions setting the mapping's primary key to the given oid values.
-
Field Details
-
_selects
-
_outer
-
-
Constructor Details
-
SelectImpl
Constructor. Supply configuration.
-
-
Method Details
-
getTablePerClassMeta
Description copied from interface:Select
get table-per-class metadata for polymorphic queries- Specified by:
getTablePerClassMeta
in interfaceSelect
-
setTablePerClassMeta
Description copied from interface:Select
Set table-per-class metadata for polymorphic queries- Specified by:
setTablePerClassMeta
in interfaceSelect
-
setJoinedTableClassMeta
Description copied from interface:Select
Set joined table metadatas for polymorphic queries- Specified by:
setJoinedTableClassMeta
in interfaceSelect
-
getJoinedTableClassMeta
Description copied from interface:Select
get joined table metadatas for polymorphic queries- Specified by:
getJoinedTableClassMeta
in interfaceSelect
-
setExcludedJoinedTableClassMeta
Description copied from interface:Select
Set joined table metadatas excluded for polymorphic queries- Specified by:
setExcludedJoinedTableClassMeta
in interfaceSelect
-
getExcludedJoinedTableClassMeta
Description copied from interface:Select
get joined table metadatas excluded for polymorphic queries- Specified by:
getExcludedJoinedTableClassMeta
in interfaceSelect
-
toOrderAlias
Helper method to return the proper order alias for the given order column index. -
setContext
Description copied from interface:Select
Set JPQL query context for this select- Specified by:
setContext
in interfaceSelect
-
ctx
Description copied from interface:Select
Return the JPQL query context of this select -
setSchemaAlias
Description copied from interface:Select
Record the initial schemaAlias of a join path- Specified by:
setSchemaAlias
in interfaceSelect
-
getConfiguration
Description copied from interface:SelectExecutor
Return the select configuration.- Specified by:
getConfiguration
in interfaceSelectExecutor
-
toSelect
Description copied from interface:SelectExecutor
Return this select as a SQL statement formatted for the current dictionary.- Specified by:
toSelect
in interfaceSelectExecutor
-
getSQL
Description copied from interface:SelectExecutor
Get the buffer if it has been computed by a previous call toSelectExecutor.toSelect(boolean, JDBCFetchConfiguration)
, if any.- Specified by:
getSQL
in interfaceSelectExecutor
-
toSelectCount
Description copied from interface:SelectExecutor
Return this select as a COUNT SQL statement formatted for the current dictionary.- Specified by:
toSelectCount
in interfaceSelectExecutor
-
getAutoDistinct
public boolean getAutoDistinct()Description copied from interface:SelectExecutor
Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.- Specified by:
getAutoDistinct
in interfaceSelectExecutor
-
setAutoDistinct
public void setAutoDistinct(boolean val) Description copied from interface:SelectExecutor
Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.- Specified by:
setAutoDistinct
in interfaceSelectExecutor
-
isDistinct
public boolean isDistinct()Description copied from interface:SelectExecutor
Whether this is a SELECT DISTINCT / UNION ALL.- Specified by:
isDistinct
in interfaceSelectExecutor
-
setDistinct
public void setDistinct(boolean distinct) Description copied from interface:SelectExecutor
Whether this is a SELECT DISTINCT / UNION ALL.- Specified by:
setDistinct
in interfaceSelectExecutor
-
isLRS
public boolean isLRS()Description copied from interface:SelectExecutor
Whether the result of this select should be treated as a large result set.- Specified by:
isLRS
in interfaceSelectExecutor
-
setLRS
public void setLRS(boolean lrs) Description copied from interface:SelectExecutor
Whether the result of this select should be treated as a large result set.- Specified by:
setLRS
in interfaceSelectExecutor
-
getExpectedResultCount
public int getExpectedResultCount()Description copied from interface:SelectExecutor
The expected result count for the query.- Specified by:
getExpectedResultCount
in interfaceSelectExecutor
-
setExpectedResultCount
public void setExpectedResultCount(int expectedResultCount, boolean force) Description copied from interface:SelectExecutor
The expected result count for the query.- Specified by:
setExpectedResultCount
in interfaceSelectExecutor
force
- if false, the count will be discarded if this select has any to-many eager joins that would throw off the result count
-
getJoinSyntax
public int getJoinSyntax()Description copied from interface:SelectExecutor
The join syntax for this select, as one of the syntax constants fromJoinSyntaxes
.- Specified by:
getJoinSyntax
in interfaceSelectExecutor
-
setJoinSyntax
public void setJoinSyntax(int joinSyntax) Description copied from interface:SelectExecutor
The join syntax for this select, as one of the syntax constants fromJoinSyntaxes
.- Specified by:
setJoinSyntax
in interfaceSelectExecutor
-
supportsRandomAccess
public boolean supportsRandomAccess(boolean forUpdate) Description copied from interface:SelectExecutor
Return whether this select can support a random access result set type.- Specified by:
supportsRandomAccess
in interfaceSelectExecutor
-
supportsLocking
public boolean supportsLocking()Description copied from interface:SelectExecutor
Whether this select can be executed for update.- Specified by:
supportsLocking
in interfaceSelectExecutor
-
hasMultipleSelects
public boolean hasMultipleSelects()Description copied from interface:SelectExecutor
Affirm if this receiver requires more than one selects to fetch its data.- Specified by:
hasMultipleSelects
in interfaceSelectExecutor
-
getCount
Description copied from interface:SelectExecutor
Return the number of instances matching this select.- Specified by:
getCount
in interfaceSelectExecutor
- Throws:
SQLException
-
execute
Description copied from interface:SelectExecutor
Execute this select in the context of the given store manager.- Specified by:
execute
in interfaceSelectExecutor
- Throws:
SQLException
-
execute
public Result execute(JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel) throws SQLException Description copied from interface:SelectExecutor
Execute this select in the context of the given store manager.- Specified by:
execute
in interfaceSelectExecutor
- Throws:
SQLException
-
execute
protected Result execute(StoreContext ctx, JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel) throws SQLException Execute this select in the context of the given store manager. The context is passed in separately for profiling purposes.- Throws:
SQLException
-
prepareStatement
protected PreparedStatement prepareStatement(Connection conn, SQLBuffer sql, JDBCFetchConfiguration fetch, int rsType, int rsConcur, boolean isLRS) throws SQLException This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.- Throws:
SQLException
-
prepareStatement
This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.- Throws:
SQLException
-
executeQuery
protected ResultSet executeQuery(Connection conn, PreparedStatement stmnt, SQLBuffer sql, boolean isLRS, JDBCStore store) throws SQLException This method is to provide override for non-JDBC or JDBC-like implementation of executing query.- Throws:
SQLException
-
executeQuery
public ResultSet executeQuery(Connection conn, PreparedStatement stmnt, String sql, JDBCStore store, Object[] params, Column[] cols) throws SQLException This method is to provide override for non-JDBC or JDBC-like implementation of executing query.- Throws:
SQLException
-
getCount
This method is to provide override for non-JDBC or JDBC-like implementation of getting count from the result set.- Throws:
SQLException
-
getEagerResult
public Result getEagerResult(Connection conn, PreparedStatement stmnt, ResultSet rs, JDBCStore store, JDBCFetchConfiguration fetch, boolean forUpdate, SQLBuffer sql) throws SQLException This method is to provide override for non-JDBC or JDBC-like implementation of executing eager selects.- Throws:
SQLException
-
indexOf
public int indexOf()Description copied from interface:Select
The index of this select within the UNION, or 0. -
getSubselects
Description copied from interface:Select
Return this select's subselects, or empty collection if none.- Specified by:
getSubselects
in interfaceSelect
-
getParent
Description copied from interface:Select
Return the parent of this select, if it is a subselect. -
getSubselectPath
Description copied from interface:Select
Return the subselect path for this select, if it is a subselect.- Specified by:
getSubselectPath
in interfaceSelect
-
setParent
Description copied from interface:Select
Turn this select into a subselect of the given instance. -
setHasSubselect
public void setHasSubselect(boolean hasSub) Description copied from interface:Select
Set the flag to indicate whether this Select has internally generated subselect- Specified by:
setHasSubselect
in interfaceSelect
-
getHasSubselect
public boolean getHasSubselect()Description copied from interface:Select
Return the flag to indicate whether this Select has internally generated subselect- Specified by:
getHasSubselect
in interfaceSelect
-
getAliases
-
removeAlias
-
getTables
-
removeTable
-
getFromSelect
Description copied from interface:Select
Another select instance that creates a temporary table from which this select pulls data.- Specified by:
getFromSelect
in interfaceSelect
-
setFromSelect
Description copied from interface:Select
Another select instance that creates a temporary table from which this select pulls data.- Specified by:
setFromSelect
in interfaceSelect
-
hasEagerJoin
public boolean hasEagerJoin(boolean toMany) Description copied from interface:Select
Whether this select has an eager join of the specified type.- Specified by:
hasEagerJoin
in interfaceSelect
-
hasJoin
public boolean hasJoin(boolean toMany) Description copied from interface:Select
Whether this select has a join of the specified type. -
isSelected
Description copied from interface:Select
Return whether the given table is being used in this select.- Specified by:
isSelected
in interfaceSelect
-
getTableAliases
Description copied from interface:Select
Return the set of all used table aliases.- Specified by:
getTableAliases
in interfaceSelect
-
getSelects
Description copied from interface:Select
Return the actualVal
s andColumn
s that were selected, in the order that they were selected.- Specified by:
getSelects
in interfaceSelect
-
getSelectAliases
Description copied from interface:Select
Return the aliases of all selected columns and all selected buffers, in the order they were selected. Each alias may be either a string or aSQLBuffer
.- Specified by:
getSelectAliases
in interfaceSelect
-
getIdentifierAliases
Description copied from interface:Select
Get the aliases for identifier columns that can be used in COUNT selects to find the number of matches. Each alias will be a string. If no identifier columns have been nominated, then all column alises are returned.- Specified by:
getIdentifierAliases
in interfaceSelect
-
getOrdering
Description copied from interface:Select
Return the ordering SQL for this select.- Specified by:
getOrdering
in interfaceSelect
-
getGrouping
Description copied from interface:Select
Return the grouping SQL for this select.- Specified by:
getGrouping
in interfaceSelect
-
getWhere
Description copied from interface:Select
Return the WHERE clause, minus any necessary end joins. -
getHaving
Description copied from interface:Select
Return the HAVING clause, or null if none. -
addJoinClassConditions
public void addJoinClassConditions()Description copied from interface:Select
Apply class conditions from relation joins. This may affect the return values ofSelect.getJoins()
,Select.getJoinIterator()
, andSelect.getWhere()
.- Specified by:
addJoinClassConditions
in interfaceSelect
-
getJoins
Description copied from interface:Select
Return the top-level joins for this select. -
getJoinIterator
Description copied from interface:Select
Return the top-levelJoin
elements for this select.- Specified by:
getJoinIterator
in interfaceSelect
-
getStartIndex
public long getStartIndex()Description copied from interface:Select
The result start index.- Specified by:
getStartIndex
in interfaceSelect
-
getEndIndex
public long getEndIndex()Description copied from interface:Select
The result end index.- Specified by:
getEndIndex
in interfaceSelect
-
setRange
public void setRange(long start, long end) Description copied from interface:Select
Set the result range for this select. -
getColumnAlias
Description copied from interface:Select
Return the alias for the given column.- Specified by:
getColumnAlias
in interfaceSelect
-
getColumnAlias
Description copied from interface:Select
Return the alias for the given column.- Specified by:
getColumnAlias
in interfaceSelect
-
getColumnAlias
Description copied from interface:Select
Return the alias for the given column.- Specified by:
getColumnAlias
in interfaceSelect
-
getColumnAlias
Description copied from interface:Select
Return the alias for the given column.- Specified by:
getColumnAlias
in interfaceSelect
-
getColumnAlias
Return the alias for the give column- Specified by:
getColumnAlias
in interfaceSelect
-
isAggregate
public boolean isAggregate()Description copied from interface:Select
Return true if this is an aggregate select.- Specified by:
isAggregate
in interfaceSelect
-
setAggregate
public void setAggregate(boolean agg) Description copied from interface:Select
Set to true for aggregate selects.- Specified by:
setAggregate
in interfaceSelect
-
isLob
public boolean isLob()Description copied from interface:Select
Return true if this select includes a LOB. -
setLob
public void setLob(boolean lob) Description copied from interface:Select
Set to true for selects that include LOB columns. -
clearSelects
public void clearSelects()Description copied from interface:Select
Clear the existing column selects.- Specified by:
clearSelects
in interfaceSelect
-
select
Description copied from interface:Select
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
. -
select
Description copied from interface:Select
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
. -
select
Description copied from interface:Select
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
. -
select
Description copied from interface:Select
Select the given SQL; the given id object is an identifier to use when retrieving the corresponding value from aResult
. -
selectPlaceholder
Description copied from interface:Select
Select the given SQL as a placeholder for a UNION element.- Specified by:
selectPlaceholder
in interfaceSelect
-
insertPlaceholder
Insert a placeholder at the given index; use a negative index to count from the back of the select list. -
clearPlaceholderSelects
public void clearPlaceholderSelects()Clear selected placeholders, and return removed select indexes. -
select
Description copied from interface:Select
Select the given column. -
select
Description copied from interface:Select
Select the given column. -
select
Description copied from interface:Select
Select the given columns. -
select
Description copied from interface:Select
Select the given columns. -
select
public void select(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager) Description copied from interface:Select
Select the columns of the given mapping, possibly including subclasses. This method should be called after all where conditions are added in case the given mapping batches other selects. -
select
public void select(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager, Joins joins) Description copied from interface:Select
Select the columns of the given mapping, possibly including subclasses. This method should be called after all where conditions are added in case the given mapping batches other selects. -
selectIdentifier
Description copied from interface:Select
Select the given column as one that can be used to get a count of distinct matches. It is not necessary to designate distinct identifiers when eagerly traversing the entire result of the select or when not using an LRSSize setting ofcount
.- Specified by:
selectIdentifier
in interfaceSelect
- Returns:
- true if selected
-
selectIdentifier
Description copied from interface:Select
Select the given column as one that can be used to get a count of distinct matches. It is not necessary to designate distinct identifiers when eagerly traversing the entire result of the select or when not using an LRSSize setting ofcount
.- Specified by:
selectIdentifier
in interfaceSelect
- Returns:
- true if selected
-
selectIdentifier
Description copied from interface:Select
Select the given columns as ones that can be used to get a count of distinct matches. It is not necessary to designate distinct identifiers when eagerly traversing the entire result of the select or when not using an LRSSize setting ofcount
.- Specified by:
selectIdentifier
in interfaceSelect
- Returns:
- bit set of indexes of columns that were selected
-
selectIdentifier
Description copied from interface:Select
Select the given columns as ones that can be used to get a count of distinct matches. It is not necessary to designate distinct identifiers when eagerly traversing the entire result of the select or when not using an LRSSize setting ofcount
.- Specified by:
selectIdentifier
in interfaceSelect
- Returns:
- bit set of indexes of columns that were selected
-
selectIdentifier
public void selectIdentifier(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager) Description copied from interface:Select
Select the columns of the given mapping, possibly including subclasses. This method should be called after all where conditions are added in case the given mapping batches other selects. The primary key columns of the mapping can be used to get a count of distinct matches. It is not necessary to designate distinct identifiers when eagerly traversing the entire result of the select or when not using an LRSSize setting ofcount
.- Specified by:
selectIdentifier
in interfaceSelect
-
selectIdentifier
public void selectIdentifier(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, int eager, Joins joins) Description copied from interface:Select
Select the columns of the given mapping, possibly including subclasses. This method should be called after all where conditions are added in case the given mapping batches other selects. The primary key columns of the mapping can be used to get a count of distinct matches. It is not necessary to designate distinct identifiers when eagerly traversing the entire result of the select or when not using an LRSSize setting ofcount
.- Specified by:
selectIdentifier
in interfaceSelect
-
selectPrimaryKey
Description copied from interface:Select
Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.- Specified by:
selectPrimaryKey
in interfaceSelect
- Returns:
- bit set of indexes of pk columns that were selected
-
selectPrimaryKey
Description copied from interface:Select
Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.- Specified by:
selectPrimaryKey
in interfaceSelect
- Returns:
- bit set of indexes of pk columns that were selected
-
orderByPrimaryKey
Description copied from interface:Select
Order on the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id. Optionally selects ordering data if not already selected.- Specified by:
orderByPrimaryKey
in interfaceSelect
-
orderByPrimaryKey
Description copied from interface:Select
Select and order on the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id. Optionally selects ordering data if not already selected.- Specified by:
orderByPrimaryKey
in interfaceSelect
-
orderByPrimaryKey
public int orderByPrimaryKey(ClassMapping mapping, boolean asc, Joins joins, boolean sel, boolean aliasOrder) Allow unions to set aliases on order columns. -
orderBy
Description copied from interface:Select
Order by the given column. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Order by the given column. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Order by the given columns. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Order by the given columns. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Add an ORDER BY clause. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Add an ORDER BY clause. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Add an ORDER BY clause. Optionally selects ordering data if not already selected. -
orderBy
Description copied from interface:Select
Add an ORDER BY clause. Optionally selects ordering data if not already selected. -
clearOrdering
public void clearOrdering()Description copied from interface:Select
Clear odering conditions.- Specified by:
clearOrdering
in interfaceSelect
-
wherePrimaryKey
Description copied from interface:Select
Add where conditions setting the mapping's primary key to the given oid values. If the given mapping does not use oid values for its primary key, we will recursively join to its superclass until we find an ancestor that does.- Specified by:
wherePrimaryKey
in interfaceSelect
-
whereForeignKey
Description copied from interface:Select
Add where conditions setting the given foreign key to the given oid values.- Specified by:
whereForeignKey
in interfaceSelect
- See Also:
-
where
Description copied from interface:Select
Add the given where conditions. -
where
Description copied from interface:Select
Add the given where conditions. -
where
Description copied from interface:Select
Add the given where conditions. -
where
Description copied from interface:Select
Add the given where conditions. -
where
Description copied from interface:Select
Add the given where conditions. -
having
Description copied from interface:Select
Add the given having conditions. -
having
Description copied from interface:Select
Add the given having conditions. -
having
Description copied from interface:Select
Add the given having conditions. -
having
Description copied from interface:Select
Add the given having conditions. -
groupBy
Description copied from interface:Select
Add a GROUP BY clause. -
groupBy
Description copied from interface:Select
Add a GROUP BY clause. -
groupBy
Description copied from interface:Select
Add a GROUP BY clause. -
groupBy
Description copied from interface:Select
Add a GROUP BY clause. -
groupBy
Description copied from interface:Select
Group by the given column. -
groupBy
Description copied from interface:Select
Group by the given column. -
groupBy
Description copied from interface:Select
Group by the given columns. -
groupBy
Description copied from interface:Select
Group by the given columns. -
groupBy
public void groupBy(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch) Description copied from interface:Select
Group by the columns of the given mapping, possibly including subclasses. Assumes EAGER_NONE. -
groupBy
public void groupBy(ClassMapping mapping, int subclasses, JDBCStore store, JDBCFetchConfiguration fetch, Joins joins) Description copied from interface:Select
Group by the columns of the given mapping, possibly including subclasses. Assumes EAGER_NONE. -
whereClone
Description copied from interface:Select
Return a SELECT with the same joins and where conditions as this one.- Specified by:
whereClone
in interfaceSelect
- Parameters:
sels
- number of selects to UNION together; ignored if <= 1
-
fullClone
Description copied from interface:Select
Return a SELECT that is a complete clone of this one. -
eagerClone
Description copied from interface:Select
Return a select that will be eagerly executed with this one, or null if the select cannot be created for the given key and join type. If the join type is inner or outer, then this select instance will be returned. Otherwise, the returned select will have a clone of this select's where conditions and joins but will be independent.- Specified by:
eagerClone
in interfaceSelect
- Parameters:
key
- the key for the eager selecteagerType
- one of the EAGER_* constantstoMany
- whether the eager join is to-manysels
- number of selects to UNION together; ignored if <= 1
-
getEagerMap
Return view of eager selects. May be null. -
logEagerRelations
public void logEagerRelations()Description copied from interface:Select
Extended trace that logs eager relations- Specified by:
logEagerRelations
in interfaceSelect
-
getEager
Description copied from interface:Select
Return the eager select for the given key. -
newJoins
Description copied from interface:Select
Return a new instance to use for joining. -
newOuterJoins
Description copied from interface:Select
Return a new instance to use for outer joining.- Specified by:
newOuterJoins
in interfaceSelect
-
append
Description copied from interface:Select
Append the given joins to the given buffer. -
and
Description copied from interface:Select
AND the given joins together. The given joins will be hollowed in the process. -
getSelect
-
or
Description copied from interface:Select
OR the given joins together. The common joins will be removed in the process. -
outer
Description copied from interface:Select
Return a join set making the given joins outer joins. -
toString
Description copied from interface:Select
Implement toString to generate SQL string for profiling/debuggging. -
isOuter
public boolean isOuter()Description copied from interface:Joins
Whether this joins path results in outer joins. -
setOuter
public org.apache.openjpa.jdbc.sql.PathJoins setOuter(boolean outer) -
isDirty
public boolean isDirty() -
path
-
getPathStr
-
joins
public org.apache.openjpa.jdbc.sql.JoinSet joins() -
joinCount
public int joinCount() -
nullJoins
public void nullJoins() -
isEmpty
public boolean isEmpty()Description copied from interface:Joins
Whether we have any joins. -
crossJoin
Description copied from interface:Joins
Perform a cross join on the given tables. -
join
Description copied from interface:Joins
Join the columns of the given foreign key. -
outerJoin
Description copied from interface:Joins
Join the columns of the given foreign key. -
joinRelation
public Joins joinRelation(String name, ForeignKey fk, ClassMapping target, int subs, boolean inverse, boolean toMany) Description copied from interface:Joins
Join the columns of the given foreign key, which represents a relation via the given field name.- Specified by:
joinRelation
in interfaceJoins
-
outerJoinRelation
public Joins outerJoinRelation(String name, ForeignKey fk, ClassMapping target, int subs, boolean inverse, boolean toMany) Description copied from interface:Joins
Join the columns of the given foreign key, which represents a relation via the given field name.- Specified by:
outerJoinRelation
in interfaceJoins
-
setVariable
Description copied from interface:Joins
Set the variable name being traversed into with the next join.- Specified by:
setVariable
in interfaceJoins
-
setSubselect
Description copied from interface:Joins
Set the subquery alias.- Specified by:
setSubselect
in interfaceJoins
-
clone
-
newSelects
-
getDictionary
- Specified by:
getDictionary
in interfaceSelect
-
setJoinContext
Description copied from interface:Joins
Set subquery context when traversing into the next join is in transition from parent context to subquery.- Specified by:
setJoinContext
in interfaceJoins
-
moveJoinsToParent
public void moveJoinsToParent()Description copied from interface:Joins
Move joins that belong to subquery's parent- Specified by:
moveJoinsToParent
in interfaceJoins
-