Class FetchDBMethodGenerator

All Implemented Interfaces:
MethodGenerator
Direct Known Subclasses:
EntityDBFetcherMethodGenerator, FetchCountDBMethodGenerator, FetchMappedObjectDBMethodGenerator, FetchMultiTableDBMethodGenerator, FetchNodeImplementationDBMethodGenerator, FetchSingleTableInterfaceDBMethodGenerator

public abstract class FetchDBMethodGenerator extends DBMethodGenerator<ObjectField>
Abstract generator for various database fetching methods.
  • Field Details

    • resolverKeyParamName

      protected final String resolverKeyParamName
    • isRoot

      protected final boolean isRoot
  • Constructor Details

  • Method Details

    • getInitialKey

      protected CodeBlock getInitialKey(FetchContext context)
    • createSelectJoins

      protected CodeBlock createSelectJoins(Set<SQLJoinStatement> joinList)
      Parameters:
      joinList - List of join statements that should be applied to a select query.
      Returns:
      Code block containing all the join statements and their conditions.
    • createSelectConditions

      protected CodeBlock createSelectConditions(List<CodeBlock> conditionList, boolean hasWhere)
      Parameters:
      conditionList - List of conditional statements that should be appended after the where-statement.
      Returns:
      Code block which declares all the extra conditions that will be used in a select query.
    • createAliasDeclarations

      protected static CodeBlock createAliasDeclarations(Set<Alias> aliasSet)
      Parameters:
      aliasSet - Set of aliases to be defined.
      Returns:
      Code block which declares all the aliases that will be used in a select query.
    • createAliasDeclarations

      protected static CodeBlock createAliasDeclarations(Alias alias)
    • generateCorrelatedSubquery

      protected CodeBlock generateCorrelatedSubquery(GenerationField field, FetchContext context)
    • wrapInMultiset

      protected CodeBlock wrapInMultiset(CodeBlock contents)
    • wrapInField

      protected CodeBlock wrapInField(CodeBlock contents)
    • generateSelectRow

      protected CodeBlock generateSelectRow(FetchContext context)
      This method recursively generates one single row method call. It deduces how each layer of row call should be structured by keeping track of joins and following field references.
      Returns:
      Code block which contains the entire recursive structure of the row statement.
    • getSelectCodeAndFieldSource

      protected org.apache.commons.lang3.tuple.Pair<CodeBlock,String> getSelectCodeAndFieldSource(GenerationField field, FetchContext context)
    • createMapping

      protected CodeBlock createMapping(FetchContext context, List<? extends GenerationField> fieldsWithoutSplitting, HashMap<String,String> referenceFieldSources, List<CodeBlock> rowElements, LinkedHashSet<KeyWrapper> keySet)
    • generateForScalarField

      protected CodeBlock generateForScalarField(GenerationField field, FetchContext context)
      Generate a single argument in the row method call.
    • generateForScalarField

      protected CodeBlock generateForScalarField(GenerationField field, FetchContext context, boolean overrideEnum)
      Generate a single argument in the row method call.
    • generateForUnionField

      protected CodeBlock generateForUnionField(GenerationField field, FetchContext context)
      Generate select row for each object within the union field
    • formatWhereContents

      protected CodeBlock formatWhereContents(FetchContext context, String resolverKeyParamName, boolean isRoot, boolean isResolverRoot)
      Returns:
      Formatted CodeBlock for the where-statement and surrounding code. Applies conditions and joins.
    • getInputConditions

      @NotNull protected @NotNull InputConditions getInputConditions(ObjectField referenceField)
    • inferFieldNamingConvention

      protected String inferFieldNamingConvention(GenerationField field)
    • createSeekAndLimitBlock

      protected CodeBlock createSeekAndLimitBlock()
    • createOrderFieldsDeclarationBlock

      protected CodeBlock createOrderFieldsDeclarationBlock(ObjectField referenceField, String actualRefTable, String tableName)
    • createOrderFieldsBlock

      protected CodeBlock createOrderFieldsBlock(ObjectField referenceField, String actualRefTable, String tableName)
    • getSpecBuilder

      @NotNull protected MethodSpec.Builder getSpecBuilder(ObjectField referenceField, TypeName refTypeName, InputParser parser)