org.datanucleus.store.rdbms.extent
Class ClassTableExtent

java.lang.Object
  extended by org.datanucleus.store.AbstractExtent
      extended by org.datanucleus.store.rdbms.extent.AbstractRDBMSExtent
          extended by org.datanucleus.store.rdbms.extent.ClassTableExtent
All Implemented Interfaces:
org.datanucleus.store.Extent, org.datanucleus.store.mapped.expression.Queryable

public class ClassTableExtent
extends AbstractRDBMSExtent
implements org.datanucleus.store.mapped.expression.Queryable

An Extent of all persistent objects backed by a class table. There are 3 inheritance strategies, and each is handled by this class but in different ways.

subclass-table Strategy

In this case a class does not have its own table and its fields are persisted to the table of a subclass. If the class requiring the Extent is the "subclass-table" class, then there will be an array of tables where objects of this type can be persisted (as the base table). For this reason the caller passes in an array of tables.

new-table Strategy

In this case the class has its own table, and so there is only one base table for the class. The array of tables passed in will be of size 1.

superclass-table Strategy

In this case the class doesn't have its own table, BUT will be persisted into the table of its superclass. In this case the array of tables passed in will be of size 1 (the superclass' table).


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER_RDBMS
          Localised messages
 
Fields inherited from class org.datanucleus.store.rdbms.extent.AbstractRDBMSExtent
query, queryResultsByIterator
 
Fields inherited from class org.datanucleus.store.AbstractExtent
candidateClass, cmd, LOCALISER, om, storeMgr, subclasses
 
Constructor Summary
ClassTableExtent(org.datanucleus.ObjectManager om, org.datanucleus.store.mapped.DatastoreClass[] tables, java.lang.Class cls, boolean subclasses, org.datanucleus.metadata.AbstractClassMetaData cmd)
          Constructor.
ClassTableExtent(org.datanucleus.ObjectManager om, org.datanucleus.store.mapped.DatastoreClass table, java.lang.Class cls, boolean subclasses, org.datanucleus.metadata.AbstractClassMetaData cmd)
          Constructor.
 
Method Summary
 boolean isEmpty()
          Returns true if this collection contains no elements.
 org.datanucleus.store.mapped.expression.QueryExpression newQueryStatement()
          Create a new query to search for the candidate classes etc.
 org.datanucleus.store.mapped.expression.QueryExpression newQueryStatement(java.lang.Class candidateClass, org.datanucleus.store.mapped.DatastoreIdentifier candidateAlias)
          Create a query to search for instances of the candidateClass and its subclasses (if required).
 org.datanucleus.store.query.ResultObjectFactory newResultObjectFactory(org.datanucleus.store.mapped.expression.QueryExpression stmt, boolean ignoreCache, java.lang.Class resultClass, boolean useFetchPlan)
          Create a new factory for objects from the ResultSet.
 
Methods inherited from class org.datanucleus.store.rdbms.extent.AbstractRDBMSExtent
close, closeAll, getFetchPlan, iterator
 
Methods inherited from class org.datanucleus.store.AbstractExtent
getCandidateClass, getObjectManager, hasSubclasses, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALISER_RDBMS

protected static final org.datanucleus.util.Localiser LOCALISER_RDBMS
Localised messages

Constructor Detail

ClassTableExtent

public ClassTableExtent(org.datanucleus.ObjectManager om,
                        org.datanucleus.store.mapped.DatastoreClass table,
                        java.lang.Class cls,
                        boolean subclasses,
                        org.datanucleus.metadata.AbstractClassMetaData cmd)
Constructor. Used for classes that have "new-table" or "superclass-table" inheritance strategies.

Parameters:
om - ObjectManager
table - Table representing the class whose extent we want
cls - Candidate class
subclasses - Whether to include subclasses of the class.
cmd - MetaData for the candidate class

ClassTableExtent

public ClassTableExtent(org.datanucleus.ObjectManager om,
                        org.datanucleus.store.mapped.DatastoreClass[] tables,
                        java.lang.Class cls,
                        boolean subclasses,
                        org.datanucleus.metadata.AbstractClassMetaData cmd)
Constructor. Used for classes that have "subclass-table" inheritance strategy, and hence can be persisted into multiple tables.

Parameters:
om - ObjectManager
tables - Tables representing the class whose extent we want
cls - Candidate class
subclasses - Whether to include subclasses of the class.
cmd - MetaData for the candidate class
Method Detail

newQueryStatement

public org.datanucleus.store.mapped.expression.QueryExpression newQueryStatement()
Create a new query to search for the candidate classes etc.

Specified by:
newQueryStatement in interface org.datanucleus.store.mapped.expression.Queryable
Returns:
The new QueryStatement.

newQueryStatement

public org.datanucleus.store.mapped.expression.QueryExpression newQueryStatement(java.lang.Class candidateClass,
                                                                                 org.datanucleus.store.mapped.DatastoreIdentifier candidateAlias)
Create a query to search for instances of the candidateClass and its subclasses (if required).

Specified by:
newQueryStatement in interface org.datanucleus.store.mapped.expression.Queryable
Parameters:
candidateClass - The candidate class
candidateAlias - Alias for the candidate
Returns:
The QueryStatement that will return the instances

newResultObjectFactory

public org.datanucleus.store.query.ResultObjectFactory newResultObjectFactory(org.datanucleus.store.mapped.expression.QueryExpression stmt,
                                                                              boolean ignoreCache,
                                                                              java.lang.Class resultClass,
                                                                              boolean useFetchPlan)
Create a new factory for objects from the ResultSet.

Specified by:
newResultObjectFactory in interface org.datanucleus.store.mapped.expression.Queryable
Parameters:
stmt - The Query Statement
ignoreCache - Whether to ignore dirty objects
resultClass - Whether to create objects of a particular class
useFetchPlan - whether to use the fetch plan to retrieve fields in the same query
Returns:
The result object factory

isEmpty

public boolean isEmpty()
Returns true if this collection contains no elements.

Specified by:
isEmpty in interface org.datanucleus.store.mapped.expression.Queryable
Returns:
Whether the extent has no elements.


Copyright © 2009. All Rights Reserved.