org.apache.openjpa.jdbc.sql
Class LogicalUnion

java.lang.Object
  extended by 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
static interface LogicalUnion.Selector
          A callback used to create the selects in a SQL union.
protected  class LogicalUnion.UnionSelect
          A select that is part of a logical union.
 
Field Summary
protected  BitSet desc
           
protected  DBDictionary dict
           
protected  ClassMapping[] mappings
           
protected  LogicalUnion.UnionSelect[] sels
           
 
Constructor Summary
  LogicalUnion(JDBCConfiguration conf, int sels)
          Constructor.
protected LogicalUnion(JDBCConfiguration conf, int sels, Select[] seeds)
          Delegate constructor.
  LogicalUnion(JDBCConfiguration conf, Select[] seeds)
          Constructor used to seed the internal selects.
 
Method Summary
 void abortUnion()
          Force the use of a series of standard selects rather than a true UNION.
 Result execute(JDBCStore store, JDBCFetchConfiguration fetch)
          Execute this select in the context of the given store manager.
 Result execute(JDBCStore store, JDBCFetchConfiguration fetch, int lockLevel)
          Execute this select in the context of the given store manager.
 boolean getAutoDistinct()
          Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.
 JDBCConfiguration getConfiguration()
          Return the select configuration.
 int getCount(JDBCStore store)
          Return the number of instances matching this select.
 int getJoinSyntax()
          The join syntax for this select, as one of the syntax constants from JoinSyntaxes.
 String getOrdering()
          Get the union-level ordering, if any.
 Select[] getSelects()
          Return the selects that make up this union.
 boolean isDistinct()
          Whether this is a SELECT DISTINCT / UNION ALL.
 boolean isLRS()
          Whether the result of this select should be treated as a large result set.
 boolean isSingleResult()
          Whether this union will return at most a single result.
 boolean isUnion()
          Whether this is a true UNION, rather than a logical combination of independent selects.
protected  LogicalUnion.UnionSelect newUnionSelect(SelectImpl seed, int pos)
          Create a new union select with the given delegate and union position.
 void select(Union.Selector selector)
          Select data using the given selector.
 void setAutoDistinct(boolean distinct)
          Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.
 void setDistinct(boolean distinct)
          Whether this is a SELECT DISTINCT / UNION ALL.
 void setJoinSyntax(int syntax)
          The join syntax for this select, as one of the syntax constants from JoinSyntaxes.
 void setLRS(boolean lrs)
          Whether the result of this select should be treated as a large result set.
 void setSingleResult(boolean single)
          Whether this union will return at most a single result.
 boolean supportsLocking()
          Whether this select can be executed for update.
 boolean supportsRandomAccess(boolean forUpdate)
          Return whether this select can support a random access result set type.
 SQLBuffer toSelect(boolean forUpdate, JDBCFetchConfiguration fetch)
          Return this select as a SQL statement formatted for the current dictionary.
 SQLBuffer toSelectCount()
          Return this select as a COUNT SQL statement formatted for the current dictionary.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 configuration
sels - 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: Union
Return the selects that make up this union.

Specified by:
getSelects in interface Union

isSingleResult

public boolean isSingleResult()
Description copied from interface: Union
Whether this union will return at most a single result. Setting this flag makes it more efficient to execute logical unions that are actually made up from multiple selects executed in batch.

Specified by:
isSingleResult in interface Union

setSingleResult

public void setSingleResult(boolean single)
Description copied from interface: Union
Whether this union will return at most a single result. Setting this flag makes it more efficient to execute logical unions that are actually made up from multiple selects executed in batch.

Specified by:
setSingleResult in interface Union

isUnion

public boolean isUnion()
Description copied from interface: Union
Whether this is a true UNION, rather than a logical combination of independent selects.

Specified by:
isUnion in interface Union

abortUnion

public void abortUnion()
Description copied from interface: Union
Force the use of a series of standard selects rather than a true UNION.

Specified by:
abortUnion in interface Union

getOrdering

public String getOrdering()
Description copied from interface: Union
Get the union-level ordering, if any.

Specified by:
getOrdering in interface Union

getConfiguration

public JDBCConfiguration getConfiguration()
Description copied from interface: SelectExecutor
Return the select configuration.

Specified by:
getConfiguration in interface SelectExecutor

toSelect

public SQLBuffer toSelect(boolean forUpdate,
                          JDBCFetchConfiguration fetch)
Description copied from interface: SelectExecutor
Return this select as a SQL statement formatted for the current dictionary.

Specified by:
toSelect in interface SelectExecutor

toSelectCount

public SQLBuffer toSelectCount()
Description copied from interface: SelectExecutor
Return this select as a COUNT SQL statement formatted for the current dictionary.

Specified by:
toSelectCount in interface SelectExecutor

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 interface SelectExecutor

setAutoDistinct

public void setAutoDistinct(boolean distinct)
Description copied from interface: SelectExecutor
Whether to automatically make results distinct when relational joins would otherwise introduce duplicates.

Specified by:
setAutoDistinct in interface SelectExecutor

isDistinct

public boolean isDistinct()
Description copied from interface: SelectExecutor
Whether this is a SELECT DISTINCT / UNION ALL.

Specified by:
isDistinct in interface SelectExecutor

setDistinct

public void setDistinct(boolean distinct)
Description copied from interface: SelectExecutor
Whether this is a SELECT DISTINCT / UNION ALL.

Specified by:
setDistinct in interface SelectExecutor

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 interface SelectExecutor

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 interface SelectExecutor

getJoinSyntax

public int getJoinSyntax()
Description copied from interface: SelectExecutor
The join syntax for this select, as one of the syntax constants from JoinSyntaxes.

Specified by:
getJoinSyntax in interface SelectExecutor

setJoinSyntax

public void setJoinSyntax(int syntax)
Description copied from interface: SelectExecutor
The join syntax for this select, as one of the syntax constants from JoinSyntaxes.

Specified by:
setJoinSyntax in interface SelectExecutor

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 interface SelectExecutor

supportsLocking

public boolean supportsLocking()
Description copied from interface: SelectExecutor
Whether this select can be executed for update.

Specified by:
supportsLocking in interface SelectExecutor

getCount

public int getCount(JDBCStore store)
             throws SQLException
Description copied from interface: SelectExecutor
Return the number of instances matching this select.

Specified by:
getCount in interface SelectExecutor
Throws:
SQLException

execute

public Result execute(JDBCStore store,
                      JDBCFetchConfiguration fetch)
               throws SQLException
Description copied from interface: SelectExecutor
Execute this select in the context of the given store manager.

Specified by:
execute in interface SelectExecutor
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 interface SelectExecutor
Throws:
SQLException

select

public void select(Union.Selector selector)
Description copied from interface: Union
Select data using the given selector.

Specified by:
select in interface Union

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006 Apache Software Foundation. All Rights Reserved.