public class JoinedAttributeManager extends Object implements Cloneable
Purpose: A common class to be used by ObjectLevelReadQueries and ReportItems. This Class will be used to store Joined Attribute Expressions. It will also store the indexes for object construction.
Modifier and Type | Field and Description |
---|---|
protected ExpressionBuilder |
baseExpressionBuilder
Stores the base builder for resolving joined attributes by name
|
protected ObjectBuildingQuery |
baseQuery
Stores the baseQuery
|
protected List |
dataResults
Stored all row results to -m joining.
|
protected ClassDescriptor |
descriptor
Stores the descriptor that these joins apply on
|
protected boolean |
hasOuterJoinedAttribute
PERF: Used to avoid null checks for inner attribute joining.
|
protected boolean |
isToManyJoin
Used to determine if -m joining has been used.
|
protected ArrayList |
joinedAttributeExpressions_
Stores the joined attributes added through the query
|
protected ArrayList |
joinedAttributes_
PERF: Cache the local joined attribute names.
|
protected ArrayList |
joinedMappingExpressions_
Stores the joined attributes as specified in the descriptor
|
protected HashMap |
joinedMappingIndexes_
Used internally for joining.
|
protected HashMap |
joinedMappingQueries_
Used internally for joining.
|
protected int |
parentResultIndex
Stores the result index of the parent, used for oneToMany joins
|
Constructor and Description |
---|
JoinedAttributeManager() |
JoinedAttributeManager(ClassDescriptor descriptor,
ExpressionBuilder baseBuilder,
ObjectBuildingQuery baseQuery) |
Modifier and Type | Method and Description |
---|---|
void |
addJoinedAttribute(String attributeExpression)
INTERNAL:
|
void |
addJoinedAttributeExpression(Expression attributeExpression)
INTERNAL:
|
void |
addJoinedMapping(String attributeName)
INTERNAL:
Add an attribute represented by the given attribute name to the list of joins
for this query.
|
void |
addJoinedMappingExpression(Expression mappingExpression)
INTERNAL:
Add an attribute represented by the given attribute name to the list of joins
for this query.
|
Object |
clone()
INTERNAL:
Clones the Joined Attribute Manager.
|
protected int |
computeIndexesForJoinedExpressions(List joinedExpressions,
int currentIndex,
AbstractSession session)
INTERNAL:
This method is used when computing the indexes for joined mappings.
|
int |
computeJoiningMappingIndexes(boolean includeAllSubclassFields,
AbstractSession session,
int offset)
INTERNAL:
For joining the resulting rows include the field/values for many objects.
|
void |
computeJoiningMappingQueries(AbstractSession session)
INTERNAL:
Used to optimize joining by pre-computing the nested join queries for the mappings.
|
protected void |
computeNestedQueriesForJoinedExpressions(List joinedExpressions,
AbstractSession session,
ObjectLevelReadQuery readQuery)
INTERNAL:
This method is used when computing the nested queries for joined mappings.
|
ExpressionBuilder |
getBaseExpressionBuilder()
INTERNAL:
Returns the base expression builder for this query.
|
ObjectBuildingQuery |
getBaseQuery()
INTERNAL:
Returns the base query.
|
List |
getDataResults_()
INTERNAL:
Return all of the rows fetched by the query, used for 1-m joining.
|
ClassDescriptor |
getDescriptor()
INTERNAL:
|
List |
getJoinedAttributeExpressions()
INTERNAL:
Return the attributes that must be joined.
|
List |
getJoinedAttributes()
INTERNAL:
Return the attributes that must be joined.
|
List |
getJoinedMappingExpressions()
INTERNAL:
Get the list of expressions that represent elements that are joined because of their
mapping for this query.
|
Map |
getJoinedMappingIndexes_()
INTERNAL:
Return the joined mapping indexes, used to compute mapping row partitions.
|
Map |
getJoinedMappingQueries_()
INTERNAL:
Return the joined mapping queries, used optimize joining, only compute the nested queries once.
|
int |
getParentResultIndex() |
boolean |
hasJoinedAttributeExpressions()
INTERNAL:
Return the attributes that must be joined.
|
boolean |
hasJoinedAttributes()
INTERNAL:
Return if any attributes are joined.
|
boolean |
hasJoinedExpressions()
INTERNAL:
THis methos checks bot attribute expressions and mapping expressions and
determines if there are any joins to be made
|
boolean |
hasJoinedMappingExpressions()
INTERNAL:
Return the attributes that must be joined.
|
boolean |
hasOuterJoinedAttributeQuery()
INTERNAL:
PERF: Return if the query uses any outer attribute joins, used to avoid null checks in building objects.
|
protected boolean |
isAttributeExpressionJoined(String attributeName)
INTERNAL:
Return if the attribute is specified for joining.
|
boolean |
isAttributeJoined(ClassDescriptor mappingDescriptor,
String attributeName)
INTERNAL:
Return if the attribute is specified for joining.
|
protected boolean |
isAttributeMappingJoined(String attributeName)
INTERNAL:
Return whether the given attribute is joined as a result of a join on a mapping
|
protected boolean |
isAttributeNameInJoinedExpressionList(String attributeName,
List joinedExpressionList)
Iterate through a list of expressions searching for the given attribute name.
|
boolean |
isToManyJoin()
INTERNAL:
Return if the query uses any -m joins, and thus return duplicate/multiple rows.
|
protected void |
prepareJoinExpression(Expression expression,
AbstractSession session)
Validate and prepare the join expression.
|
void |
prepareJoinExpressions(AbstractSession session)
INTERNAL:
Validate and prepare join expressions.
|
void |
processJoinedMappings()
INTERNAL:
This method collects the Joined Mappings from the descriptor and initializes
them
|
void |
reset()
INTERNAL:
Reset the JoinedAttributeManager.
|
protected void |
setBaseExpressionBuilder(ExpressionBuilder builder)
INTERNAL:
This method is called from within this package, it is used when
initializing a ReportItem
|
void |
setBaseQuery(ObjectLevelReadQuery query)
INTERNAL:
This method is called from within this package it is used when
initializing a report Item
|
void |
setDataResults(List dataResults,
AbstractSession session)
INTERNAL:
Set all of the rows fetched by the query, used for 1-m joining.
|
void |
setDescriptor(ClassDescriptor descriptor)
INTERNAL:
Called to set the descriptor on a Join Managerwith in a ReportItem, durring
initialization, and durring DatabaseQuery.checkDescriptor
|
protected void |
setIsOuterJoinedAttributeQuery(boolean isOuterJoinedAttribute)
INTERNAL:
PERF: Set if the query uses any outer attribute joins, used to avoid null checks in building objects.
|
protected void |
setIsToManyJoinQuery(boolean isToManyJoin)
INTERNAL:
Set if the query uses any -m joins, and thus return duplicate/multiple rows.
|
void |
setJoinedAttributeExpressions_(List joinedExpressions)
INTERNAL:
Set the list of expressions that represent elements that are joined because of their
mapping for this query.
|
void |
setJoinedMappingExpressions_(List joinedMappingExpressions)
INTERNAL:
Set the list of expressions that represent elements that are joined because of their
mapping for this query.
|
void |
setJoinedMappingIndexes_(HashMap joinedMappingIndexes)
INTERNAL:
Set the joined mapping indexes, used to compute mapping row partitions.
|
protected void |
setJoinedMappingQueries_(HashMap joinedMappingQueries)
INTERNAL:
Set the joined mapping queries, used optimize joining, only compute the nested queries once.
|
void |
setParentResultIndex(int parentsResultIndex) |
ForUpdateOfClause |
setupLockingClauseForJoinedExpressions(ForUpdateOfClause lockingClause,
AbstractSession session)
INTERNAL:
Used for joining in conjunction with pessimistic locking
Iterate through a list of joined expressions and ensure expression is set on the locking
clause for each expression that represents a pessimisically locked descriptor.
|
protected ArrayList joinedAttributeExpressions_
protected ArrayList joinedMappingExpressions_
protected ArrayList joinedAttributes_
protected boolean isToManyJoin
protected boolean hasOuterJoinedAttribute
protected transient HashMap joinedMappingIndexes_
protected transient HashMap joinedMappingQueries_
protected List dataResults
protected ClassDescriptor descriptor
protected ExpressionBuilder baseExpressionBuilder
protected ObjectBuildingQuery baseQuery
protected int parentResultIndex
public JoinedAttributeManager()
public JoinedAttributeManager(ClassDescriptor descriptor, ExpressionBuilder baseBuilder, ObjectBuildingQuery baseQuery)
public void addJoinedAttribute(String attributeExpression)
public void addJoinedAttributeExpression(Expression attributeExpression)
public void addJoinedMappingExpression(Expression mappingExpression)
public void addJoinedMapping(String attributeName)
public Object clone()
public int computeJoiningMappingIndexes(boolean includeAllSubclassFields, AbstractSession session, int offset)
protected void computeNestedQueriesForJoinedExpressions(List joinedExpressions, AbstractSession session, ObjectLevelReadQuery readQuery)
public void computeJoiningMappingQueries(AbstractSession session)
protected int computeIndexesForJoinedExpressions(List joinedExpressions, int currentIndex, AbstractSession session)
#computeJoiningMappingIndexes(boolean, AbstractSession)
public ExpressionBuilder getBaseExpressionBuilder()
public ObjectBuildingQuery getBaseQuery()
public List getDataResults_()
public ClassDescriptor getDescriptor()
public List getJoinedAttributes()
public List getJoinedAttributeExpressions()
public List getJoinedMappingExpressions()
public boolean hasJoinedAttributeExpressions()
public boolean hasJoinedExpressions()
public boolean hasJoinedMappingExpressions()
public boolean hasJoinedAttributes()
public boolean hasOuterJoinedAttributeQuery()
public boolean isToManyJoin()
public boolean isAttributeJoined(ClassDescriptor mappingDescriptor, String attributeName)
protected boolean isAttributeNameInJoinedExpressionList(String attributeName, List joinedExpressionList)
protected boolean isAttributeExpressionJoined(String attributeName)
protected boolean isAttributeMappingJoined(String attributeName)
public void setJoinedAttributeExpressions_(List joinedExpressions)
public void setJoinedMappingExpressions_(List joinedMappingExpressions)
public Map getJoinedMappingIndexes_()
public Map getJoinedMappingQueries_()
protected void setJoinedMappingQueries_(HashMap joinedMappingQueries)
public void setJoinedMappingIndexes_(HashMap joinedMappingIndexes)
protected void setIsOuterJoinedAttributeQuery(boolean isOuterJoinedAttribute)
protected void setIsToManyJoinQuery(boolean isToManyJoin)
public void prepareJoinExpressions(AbstractSession session)
protected void prepareJoinExpression(Expression expression, AbstractSession session)
public void processJoinedMappings()
public void reset()
public void setBaseQuery(ObjectLevelReadQuery query)
protected void setBaseExpressionBuilder(ExpressionBuilder builder)
public void setDataResults(List dataResults, AbstractSession session)
public void setDescriptor(ClassDescriptor descriptor)
public ForUpdateOfClause setupLockingClauseForJoinedExpressions(ForUpdateOfClause lockingClause, AbstractSession session)
public void setParentResultIndex(int parentsResultIndex)
public int getParentResultIndex()
Copyright © 2024. All rights reserved.