Package org.apache.openjpa.jdbc.sql
Class LogicalUnion
- java.lang.Object
-
- org.apache.openjpa.jdbc.sql.LogicalUnion
-
- All Implemented Interfaces:
SelectExecutor,Union
public class LogicalUnion extends Object implements Union
A logical union made up of multiple distinct selects whose results are combined in memory.- Author:
- Abe White
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLogicalUnion.SelectorA callback used to create the selects in a SQL union.classLogicalUnion.UnionSelectA select that is part of a logical union.
-
Field Summary
Fields Modifier and Type Field Description protected BitSetdescprotected DBDictionarydictprotected ClassMapping[]mappingsprotected LogicalUnion.UnionSelect[]sels
-
Constructor Summary
Constructors Modifier Constructor Description LogicalUnion(JDBCConfiguration conf, int sels)Constructor.protectedLogicalUnion(JDBCConfiguration conf, int sels, Select[] seeds)Delegate constructor.LogicalUnion(JDBCConfiguration conf, Select[] seeds)Constructor used to seed the internal selects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabortUnion()Force the use of a series of standard selects rather than a true UNION.Resultexecute(JDBCStore store, JDBCFetchConfiguration fetch)Execute this select in the context of the given store manager.Resultexecute(JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel)Execute this select in the context of the given store manager.booleangetAutoDistinct()Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.JDBCConfigurationgetConfiguration()Return the select configuration.intgetCount(JDBCStore store)Return the number of instances matching this select.DBDictionarygetDBDictionary()intgetExpectedResultCount()The expected result count for the query.intgetJoinSyntax()The join syntax for this select, as one of the syntax constants fromJoinSyntaxes.StringgetOrdering()Get the union-level ordering, if any.Select[]getSelects()Return the selects that make up this union.SQLBuffergetSQL()Get the buffer if it has been computed by a previous call toSelectExecutor.toSelect(boolean, JDBCFetchConfiguration), if any.booleanhasMultipleSelects()Affirm if this receiver requires more than one selects to fetch its data.booleanisDistinct()Whether this is a SELECT DISTINCT / UNION ALL.booleanisLRS()Whether the result of this select should be treated as a large result set.booleanisUnion()Whether this is a true UNION, rather than a logical combination of independent selects.protected LogicalUnion.UnionSelectnewUnionSelect(SelectImpl seed, int pos)Create a new union select with the given delegate and union position.voidselect(Union.Selector selector)Select data using the given selector.voidsetAutoDistinct(boolean distinct)Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.voidsetDistinct(boolean distinct)Whether this is a SELECT DISTINCT / UNION ALL.voidsetExpectedResultCount(int expectedResultCount, boolean force)The expected result count for the query.voidsetJoinSyntax(int syntax)The join syntax for this select, as one of the syntax constants fromJoinSyntaxes.voidsetLRS(boolean lrs)Whether the result of this select should be treated as a large result set.booleansupportsLocking()Whether this select can be executed for update.booleansupportsRandomAccess(boolean forUpdate)Return whether this select can support a random access result set type.SQLBuffertoSelect(boolean forUpdate, JDBCFetchConfiguration fetch)Return this select as a SQL statement formatted for the current dictionary.SQLBuffertoSelectCount()Return this select as a COUNT SQL statement formatted for the current dictionary.StringtoString()
-
-
-
Field Detail
-
sels
protected final LogicalUnion.UnionSelect[] sels
-
dict
protected final DBDictionary dict
-
mappings
protected final ClassMapping[] mappings
-
desc
protected final BitSet desc
-
-
Constructor Detail
-
LogicalUnion
public LogicalUnion(JDBCConfiguration conf, int sels)
Constructor.- Parameters:
conf- system configurationsels- the number of SQL selects to union together
-
LogicalUnion
public LogicalUnion(JDBCConfiguration conf, Select[] seeds)
Constructor used to seed the internal selects.
-
LogicalUnion
protected LogicalUnion(JDBCConfiguration conf, int sels, Select[] seeds)
Delegate constructor.
-
-
Method Detail
-
newUnionSelect
protected LogicalUnion.UnionSelect newUnionSelect(SelectImpl seed, int pos)
Create a new union select with the given delegate and union position.
-
getSelects
public Select[] getSelects()
Description copied from interface:UnionReturn the selects that make up this union.- Specified by:
getSelectsin interfaceUnion
-
isUnion
public boolean isUnion()
Description copied from interface:UnionWhether this is a true UNION, rather than a logical combination of independent selects.
-
abortUnion
public void abortUnion()
Description copied from interface:UnionForce the use of a series of standard selects rather than a true UNION.- Specified by:
abortUnionin interfaceUnion
-
getOrdering
public String getOrdering()
Description copied from interface:UnionGet the union-level ordering, if any.- Specified by:
getOrderingin interfaceUnion
-
getConfiguration
public JDBCConfiguration getConfiguration()
Description copied from interface:SelectExecutorReturn the select configuration.- Specified by:
getConfigurationin interfaceSelectExecutor
-
getDBDictionary
public DBDictionary getDBDictionary()
-
toSelect
public SQLBuffer toSelect(boolean forUpdate, JDBCFetchConfiguration fetch)
Description copied from interface:SelectExecutorReturn this select as a SQL statement formatted for the current dictionary.- Specified by:
toSelectin interfaceSelectExecutor
-
getSQL
public SQLBuffer getSQL()
Description copied from interface:SelectExecutorGet the buffer if it has been computed by a previous call toSelectExecutor.toSelect(boolean, JDBCFetchConfiguration), if any.- Specified by:
getSQLin interfaceSelectExecutor
-
toSelectCount
public SQLBuffer toSelectCount()
Description copied from interface:SelectExecutorReturn this select as a COUNT SQL statement formatted for the current dictionary.- Specified by:
toSelectCountin interfaceSelectExecutor
-
getAutoDistinct
public boolean getAutoDistinct()
Description copied from interface:SelectExecutorWhether to automatically make results distinct when relational joins would otherwise introduce duplicates.- Specified by:
getAutoDistinctin interfaceSelectExecutor
-
setAutoDistinct
public void setAutoDistinct(boolean distinct)
Description copied from interface:SelectExecutorWhether to automatically make results distinct when relational joins would otherwise introduce duplicates.- Specified by:
setAutoDistinctin interfaceSelectExecutor
-
isDistinct
public boolean isDistinct()
Description copied from interface:SelectExecutorWhether this is a SELECT DISTINCT / UNION ALL.- Specified by:
isDistinctin interfaceSelectExecutor
-
setDistinct
public void setDistinct(boolean distinct)
Description copied from interface:SelectExecutorWhether this is a SELECT DISTINCT / UNION ALL.- Specified by:
setDistinctin interfaceSelectExecutor
-
isLRS
public boolean isLRS()
Description copied from interface:SelectExecutorWhether the result of this select should be treated as a large result set.- Specified by:
isLRSin interfaceSelectExecutor
-
setLRS
public void setLRS(boolean lrs)
Description copied from interface:SelectExecutorWhether the result of this select should be treated as a large result set.- Specified by:
setLRSin interfaceSelectExecutor
-
getExpectedResultCount
public int getExpectedResultCount()
Description copied from interface:SelectExecutorThe expected result count for the query.- Specified by:
getExpectedResultCountin interfaceSelectExecutor
-
setExpectedResultCount
public void setExpectedResultCount(int expectedResultCount, boolean force)Description copied from interface:SelectExecutorThe expected result count for the query.- Specified by:
setExpectedResultCountin interfaceSelectExecutorforce- 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:SelectExecutorThe join syntax for this select, as one of the syntax constants fromJoinSyntaxes.- Specified by:
getJoinSyntaxin interfaceSelectExecutor
-
setJoinSyntax
public void setJoinSyntax(int syntax)
Description copied from interface:SelectExecutorThe join syntax for this select, as one of the syntax constants fromJoinSyntaxes.- Specified by:
setJoinSyntaxin interfaceSelectExecutor
-
supportsRandomAccess
public boolean supportsRandomAccess(boolean forUpdate)
Description copied from interface:SelectExecutorReturn whether this select can support a random access result set type.- Specified by:
supportsRandomAccessin interfaceSelectExecutor
-
supportsLocking
public boolean supportsLocking()
Description copied from interface:SelectExecutorWhether this select can be executed for update.- Specified by:
supportsLockingin interfaceSelectExecutor
-
hasMultipleSelects
public boolean hasMultipleSelects()
Description copied from interface:SelectExecutorAffirm if this receiver requires more than one selects to fetch its data.- Specified by:
hasMultipleSelectsin interfaceSelectExecutor
-
getCount
public int getCount(JDBCStore store) throws SQLException
Description copied from interface:SelectExecutorReturn the number of instances matching this select.- Specified by:
getCountin interfaceSelectExecutor- Throws:
SQLException
-
execute
public Result execute(JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException
Description copied from interface:SelectExecutorExecute this select in the context of the given store manager.- Specified by:
executein interfaceSelectExecutor- Throws:
SQLException
-
execute
public Result execute(JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel) throws SQLException
Description copied from interface:SelectExecutorExecute this select in the context of the given store manager.- Specified by:
executein interfaceSelectExecutor- Throws:
SQLException
-
select
public void select(Union.Selector selector)
Description copied from interface:UnionSelect data using the given selector.
-
-