org.jpox.store.query
Class UnionIteratorStatement

java.lang.Object
  extended byorg.jpox.store.query.AbstractIteratorStatement
      extended byorg.jpox.store.query.UnionIteratorStatement

public class UnionIteratorStatement
extends AbstractIteratorStatement

Class to generate a QueryStatement for iterating through the elements of a Set. This can be in an Extent/Query for example where the user has selected a candidate class and to include/exclude subclasses. The generated query statement typically contains UNIONs for each of the possible classes involved.

To give an example, lets assume that we have class A which is the candidate and this has a subclass B. We want to find all objects of the candidate type and optionally its subclasses and we want information about what type the object is (A or B). The query will be of the form

 SELECT THIS.A_ID,'org.jpox.samples.A' as JPOXMETADATA, THIS.COLUMN1, THIS.COLUMN2 
 FROM A THIS
   LEFT OUTER JOIN B SUBELEMENT0 ON SUBELEMENT0.B_ID = THIS.A_ID
 WHERE SUBELEMENT0.B_ID IS NULL
 
 UNION
 
 SELECT THIS.A_ID,'org.jpox.samples.B' as JPOXMETADATA, THIS.COLUMN1, THIS.COLUMN2 
 FROM A THIS
   INNER JOIN B 'ELEMENT' ON 'ELEMENT'.B_ID = THIS.A_ID
 

Extent

Here we use the above arrangement, with the "AssociationEnd" being the element table and the mapping being the ID column mapping.

"Normal" Relationship

Here the join table is the candidate table, and the "AssociationEnd" would be the element table, and the mapping in the join table to join to this element table PK column.

"Inverse" Relationship

Here we use the same arrangement as the Extent case. The "AssociationEnd" is the element table, and the mapping being the ID column mapping.

Map "Key" table

Here we have the key table as the candidate, and we join to the value table. So the "AssociationEnd" is the value table, with the mapping being the mapping of the key column in the value table.

Primitive key/value in SCO table

This also supports retrieval of keys or values of a map that are stored as a column in a different table. TODO Add full documentation for all combinations supported. TODO Commonise the code with DiscriminatorIteratorStatement

Version:
$Revision: 1.20 $

Nested Class Summary
static interface UnionIteratorStatement.AssociationEnd
          One side of an association.
 
Field Summary
 
Fields inherited from class org.jpox.store.query.AbstractIteratorStatement
candidateFullClassName, candidateTable, clr, dba, includeSubclasses, LOCALISER, storeMgr
 
Constructor Summary
UnionIteratorStatement(ClassLoaderResolver clr, java.lang.Class candidateType, boolean includeSubclasses, StoreManager storeMgr, UnionIteratorStatement.AssociationEnd source)
          Constructor.
UnionIteratorStatement(ClassLoaderResolver clr, java.lang.Class candidateType, boolean includeSubclasses, StoreManager storeMgr, UnionIteratorStatement.AssociationEnd source, boolean withMetadata)
          Constructor.
UnionIteratorStatement(ClassLoaderResolver clr, java.lang.Class candidateType, boolean includeSubclasses, StoreManager storeMgr, UnionIteratorStatement.AssociationEnd source, java.lang.Boolean withMetadata)
          Constructor.
 
Method Summary
 QueryExpression getQueryStatement()
          Accessor for the Query Statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnionIteratorStatement

public UnionIteratorStatement(ClassLoaderResolver clr,
                              java.lang.Class candidateType,
                              boolean includeSubclasses,
                              StoreManager storeMgr,
                              UnionIteratorStatement.AssociationEnd source)
Constructor.

Parameters:
clr - The ClassLoaderResolver
candidateType - the candidate is who are are looking to
includeSubclasses - if the subclasses of the candidate should be included in the result
storeMgr - the store manager
source - the source for the association

UnionIteratorStatement

public UnionIteratorStatement(ClassLoaderResolver clr,
                              java.lang.Class candidateType,
                              boolean includeSubclasses,
                              StoreManager storeMgr,
                              UnionIteratorStatement.AssociationEnd source,
                              boolean withMetadata)
Constructor.

Parameters:
clr - The ClassLoaderResolver
candidateType - the candidate is who we are looking to
includeSubclasses - if the subclasses of the candidate should be included in the result
storeMgr - the store manager
source - the source for the association
withMetadata - if has subclasses, include the metadata in the query

UnionIteratorStatement

public UnionIteratorStatement(ClassLoaderResolver clr,
                              java.lang.Class candidateType,
                              boolean includeSubclasses,
                              StoreManager storeMgr,
                              UnionIteratorStatement.AssociationEnd source,
                              java.lang.Boolean withMetadata)
Constructor.

Parameters:
clr - The ClassLoaderResolver
candidateType - the candidate is who we are looking to
includeSubclasses - if the subclasses of the candidate should be included in the result
storeMgr - the store manager
source - the source for the association
withMetadata - if has subclasses, include the metadata in the query
Method Detail

getQueryStatement

public QueryExpression getQueryStatement()
Accessor for the Query Statement.

Specified by:
getQueryStatement in class AbstractIteratorStatement
Returns:
The Query Statement for iterating through objects


Copyright © -2007 . All Rights Reserved.