org.objectweb.jorm.mapper.rdb.lib
Class RdbExtentGenInfos

java.lang.Object
  extended byorg.objectweb.jorm.mapper.rdb.lib.RdbExtentGenInfos

public class RdbExtentGenInfos
extends java.lang.Object


Field Summary
 boolean debug
           
 Logger logger
           
 
Constructor Summary
RdbExtentGenInfos(Logger logger)
           
 
Method Summary
 java.util.ArrayList getAllPrimitiveElementsInGraph(Class classA, java.lang.String projectName)
          Returns the list of the primitive elements (hidden and non-hidden) for: - the class classA , - all its parents and parents of parents
 java.util.Collection getPolymorphicClassExtent(Class classA, java.lang.String projectName, java.lang.String mapperName)
          Calculates the query representing the extent of the class.
 java.util.Collection getPolymorphicClassExtent(Class classA, java.lang.String projectName, java.lang.String mapperName, boolean prefetch)
          This method is used to create the list of extent mapping infos for the class classA.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public Logger logger

debug

public boolean debug
Constructor Detail

RdbExtentGenInfos

public RdbExtentGenInfos(Logger logger)
Method Detail

getPolymorphicClassExtent

public java.util.Collection getPolymorphicClassExtent(Class classA,
                                                      java.lang.String projectName,
                                                      java.lang.String mapperName)
                                               throws PException
Calculates the query representing the extent of the class. The query will be made of an union (in case of horizontal mappings) of filtered (in case of filtered and vertical mappings) tables. Elements of the extent may come from the tables on which the class is mapped or from tables on which its sub(sub...)classes are mapped. The main problem is to retrieve those tables and in those tables the right columns mapping fields defined in the mother class knowing that: - different inheritance rules may be encountered (filtered, horizontal, vertical). Some will need union, some others will need selection - classes may be mapped on multiple tables, requiring joins to retrieve the needed columns - only tables columns mapping fields of the mother class should be included in the expression of the query - columns mapping the same field in different class mapping may have different names, thus requiring renaming for realizing the required unions How the query is calculated depends on whether the class is at the top of the hierarchy tree. 1) If is at the top, its extent is made of all the instances coming from its tables and those of its children (if they are mapped to other tables). 2) If it is in the middle of the tree and its inheritance rule is 'to-new-structures' then, none of its instances comes from its parents' tables, so we can apply the same algorithm 3) If it is in the middle and its inheritance rule is 'to-extended-structures', then its filter and those of its children must be used not to get instances of its parent class. In the first two cases, the query is created with the following formula: Q(A) = T(A) U (U (PROJECT(ATTR(A)) T)) | T in T(SUB(A)) and T != T(A) where Q(A) = query for A's extent, ATTR(A) = attributes of A, T(X) = main table for class X, SUB(A) = all sub(sub(...))classes of A In the third case, the query is created with the following formula: Q(A) = (FILTER(A) AND (AND FILTER(X))) T(A) U (U (PROJECT(ATTR(A)) T(X))) | | X in SUB_F(A) and T(X)=T(A) T in T(SUB(A) - SUB_F(A)) and T != T(A) where Q(A) = query for A's extent, ATTR(A) = attributes of A, T(X) = main table for class X, SUB_F(A) = all sub(sub(...))classes that is 'filter chained'* w/ A (*) 'filter chained' means that all inheritance link from A to X is a filter inheritance rule Actually, this is a simplification since a single class may be mapped to multiple tables and the extent be calculated by joining these tables. However, since the filters express conditions on the key and the key is entirely contained in a table, this does not change the principles discussed above but simply complexifies the expression of the formulae. Instead of T(A) (resp. T(X)) we will have the joins between A's (resp. X's) tables. Also, the case of abstract classes must be taken into account. If class A its extents is the union of the extents of its subclasses. This is true whether it defines or extends an inherited mapping or not. So there is no need to construct a "select from where" at its level.

Returns:
a collection of ExtentMappingInfos that must be unioned to get the extent
Throws:
PException

getPolymorphicClassExtent

public java.util.Collection getPolymorphicClassExtent(Class classA,
                                                      java.lang.String projectName,
                                                      java.lang.String mapperName,
                                                      boolean prefetch)
                                               throws PException
This method is used to create the list of extent mapping infos for the class classA.

Throws:
PException

getAllPrimitiveElementsInGraph

public java.util.ArrayList getAllPrimitiveElementsInGraph(Class classA,
                                                          java.lang.String projectName)
Returns the list of the primitive elements (hidden and non-hidden) for: - the class classA , - all its parents and parents of parents... - all its subclasses and subclasses of subclasses...