Class DefaultSelectTranslator
java.lang.Object
org.apache.cayenne.access.translator.select.QueryAssembler
org.apache.cayenne.access.translator.select.DefaultSelectTranslator
- All Implemented Interfaces:
- SelectTranslator
- Direct Known Subclasses:
- IngresSelectTranslator,- SQLServerSelectTranslator,- SybaseSelectTranslator
public class DefaultSelectTranslator extends QueryAssembler implements SelectTranslator
- Since:
- 4.0
- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.cayenne.access.translator.select.QueryAssemblerQueryAssembler.AddBindingListener
- 
Field SummaryFields Modifier and Type Field Description protected static int[]UNSUPPORTED_DISTINCT_TYPESFields inherited from class org.apache.cayenne.access.translator.select.QueryAssembleradapter, addBindingListener, bindings, entityResolver, query, queryMetadata, sql, translated
- 
Constructor SummaryConstructors Constructor Description DefaultSelectTranslator(Query query, DbAdapter adapter, EntityResolver entityResolver)
- 
Method SummaryModifier and Type Method Description protected voidappendGroupByColumn(StringBuilder buffer, Map.Entry<ColumnDescriptor,List<DbAttributeBinding>> entry)Append single column to GROUP BY clauseprotected voidappendGroupByColumns(StringBuilder buffer, Map<ColumnDescriptor,List<DbAttributeBinding>> groupByColumns)Append columns to GROUP BY clauseprotected voidappendLimitAndOffsetClauses(StringBuilder buffer)Handles appending optional limit and offset clauses.protected voidappendSelectColumns(StringBuilder buffer, List<String> selectColumnExpList)protected StringbuildDistinctStatement()Allows subclasses to insert their own dialect of DISTINCT statement to improve performance.protected List<ColumnDescriptor>buildResultColumns()protected JoinStackcreateJoinStack()voiddbRelationshipAdded(DbRelationship relationship, JoinType joinType, String joinSplitAlias)Appends a join with given semantics to the query.protected voiddoTranslate()StringgetAliasForExpression(Expression exp)Map<ObjAttribute,ColumnDescriptor>getAttributeOverrides()Returns a map of ColumnDescriptors keyed by ObjAttribute for columns that may need to be reprocessed manually due to incompatible mappings along the inheritance hierarchy.StringgetCurrentAlias()Returns an alias of the table which is currently at the top of the join stack.protected JoinStackgetJoinStack()ColumnDescriptor[]getResultColumns()Returns a list of ColumnDescriptors for the query columns.booleanhasJoins()booleanisSuppressingDistinct()Returns true if SelectTranslator determined that a query requiring DISTINCT can't be run with DISTINCT keyword for internal reasons.protected static booleanisUnsupportedForDistinct(int type)voidresetJoinStack()A callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.booleansupportsTableAliases()Always returns true.Methods inherited from class org.apache.cayenne.access.translator.select.QueryAssembleraddToParamList, ensureTranslated, getAdapter, getBindings, getEntityResolver, getPathAliases, getQuery, getQueryMetadata, getSql, setAddBindingListenerMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cayenne.access.translator.select.SelectTranslatorgetBindings, getSql
- 
Field Details- 
UNSUPPORTED_DISTINCT_TYPESprotected static final int[] UNSUPPORTED_DISTINCT_TYPES
 
- 
- 
Constructor Details- 
DefaultSelectTranslator
 
- 
- 
Method Details- 
isUnsupportedForDistinctprotected static boolean isUnsupportedForDistinct(int type)
- 
getJoinStack
- 
createJoinStack
- 
doTranslateprotected void doTranslate()- Specified by:
- doTranslatein class- QueryAssembler
 
- 
buildDistinctStatementAllows subclasses to insert their own dialect of DISTINCT statement to improve performance.- Returns:
- string representing the DISTINCT statement
- Since:
- 4.0
 
- 
appendSelectColumns- Since:
- 3.1
 
- 
appendGroupByColumnsprotected void appendGroupByColumns(StringBuilder buffer, Map<ColumnDescriptor,List<DbAttributeBinding>> groupByColumns)Append columns to GROUP BY clause- Since:
- 4.0
 
- 
appendGroupByColumnprotected void appendGroupByColumn(StringBuilder buffer, Map.Entry<ColumnDescriptor,List<DbAttributeBinding>> entry)Append single column to GROUP BY clause- Since:
- 4.0
 
- 
appendLimitAndOffsetClausesHandles appending optional limit and offset clauses. This implementation does nothing, deferring to subclasses to define the LIMIT/OFFSET clause syntax.- Since:
- 3.0
 
- 
getCurrentAliasDescription copied from class:QueryAssemblerReturns an alias of the table which is currently at the top of the join stack.- Specified by:
- getCurrentAliasin class- QueryAssembler
 
- 
getResultColumnsReturns a list of ColumnDescriptors for the query columns.- Specified by:
- getResultColumnsin interface- SelectTranslator
- Since:
- 1.2
 
- 
getAttributeOverridesReturns a map of ColumnDescriptors keyed by ObjAttribute for columns that may need to be reprocessed manually due to incompatible mappings along the inheritance hierarchy.- Specified by:
- getAttributeOverridesin interface- SelectTranslator
- Since:
- 1.2
 
- 
isSuppressingDistinctpublic boolean isSuppressingDistinct()Returns true if SelectTranslator determined that a query requiring DISTINCT can't be run with DISTINCT keyword for internal reasons. If this method returns true, DataNode may need to do in-memory distinct filtering.- Specified by:
- isSuppressingDistinctin interface- SelectTranslator
- Since:
- 1.1
 
- 
buildResultColumns
- 
resetJoinStackpublic void resetJoinStack()Description copied from class:QueryAssemblerA callback invoked by a child qualifier or ordering processor allowing query assembler to reset its join stack.- Specified by:
- resetJoinStackin class- QueryAssembler
- Since:
- 3.0
 
- 
dbRelationshipAddedpublic void dbRelationshipAdded(DbRelationship relationship, JoinType joinType, String joinSplitAlias)Description copied from class:QueryAssemblerAppends a join with given semantics to the query.- Specified by:
- dbRelationshipAddedin class- QueryAssembler
- Since:
- 3.0
 
- 
supportsTableAliasespublic boolean supportsTableAliases()Always returns true.- Overrides:
- supportsTableAliasesin class- QueryAssembler
 
- 
getAliasForExpression- Specified by:
- getAliasForExpressionin class- QueryAssembler
 
- 
hasJoinspublic boolean hasJoins()- Specified by:
- hasJoinsin interface- SelectTranslator
- Returns:
- do query has at least one join
- Since:
- 4.0
 
 
-