Package no.sikt.graphitron.generators.db
Class NestedFetchDBMethodGenerator
java.lang.Object
no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator<ObjectField,ObjectDefinition>
no.sikt.graphitron.generators.abstractions.DBMethodGenerator<ObjectField>
no.sikt.graphitron.generators.db.FetchDBMethodGenerator
no.sikt.graphitron.generators.db.NestedFetchDBMethodGenerator
- All Implemented Interfaces:
MethodGenerator
- Direct Known Subclasses:
EntitySelectHelperDBMethodGenerator,NodeSelectHelperDBMethodGenerator,SelectHelperDBMethodGenerator
Abstract base class for generators that create nested helper methods for database query generation.
This class provides the infrastructure and logic for generating private static helper methods that extract SelectField row mapping logic for record types. Helper methods improve compilation performance by reducing method complexity and enable reuse of mapping logic across different query contexts.
Subclasses (like FetchMappedObjectDBMethodGenerator) extend this to generate the main query
methods while inheriting all helper method generation capabilities and shared state management.
Helper Method Generation Rules:
- Helper methods are generated for record types with tables, list fields, or fields with @reference
- Error types (marked with @error) never generate helpers
- Split queries receive the target table as a parameter
- Other fields receive base table parameters with alias declarations in the method body
- Only aliases actually referenced in the generated SELECT are declared
- Circular references are detected and prevented using visited type tracking
- Input parameters are omitted from split query helpers (applied at main method level)
Special Patterns:
- Container Pattern - At depth 0, non-table types with input arguments traverse directly to nested fields without generating a helper (e.g., FilmContainer wrapping Film query)
- Wrapper Types - Non-table singular types without @reference recurse to children without generating helpers (e.g., LanguageWrapper.originalLanguage)
- Helper Naming - Nested helpers use parent method name as prefix with depth indicators (e.g., queryForQuery_customer_d1_address). Uniqueness ensured with counters for duplicate paths.
State Management:
This class maintains shared state (NestedFetchDBMethodGenerator.MethodGenerationState, NestedFetchDBMethodGenerator.HelperGenerationContext)
that is accessible to subclasses during method generation to ensure consistent naming and proper
depth tracking for nested helper methods.- See Also:
-
Field Summary
Fields inherited from class no.sikt.graphitron.generators.db.FetchDBMethodGenerator
conditionsShouldFallbackToFalse, ELEMENT_NAME, resolverKeyParamNameFields inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
dependencyMap, localObject, processedSchema -
Constructor Summary
ConstructorsConstructorDescriptionNestedFetchDBMethodGenerator(ObjectDefinition localObject, ProcessedSchema processedSchema) -
Method Summary
Modifier and TypeMethodDescriptionno.sikt.graphitron.javapoet.MethodSpecgenerate(ObjectField field) List<no.sikt.graphitron.javapoet.MethodSpec> generateNested(ObjectField field) protected no.sikt.graphitron.javapoet.CodeBlockgetHelperMethodCallForNestedField(ObjectField field, FetchContext context) Generates a helper method call for nested record type fields.Methods inherited from class no.sikt.graphitron.generators.db.FetchDBMethodGenerator
createAliasDeclarations, createAliasDeclarations, createOrderFieldsBlock, createOrderFieldsDeclarationBlock, createSeekAndLimitBlock, createSelectConditions, createSelectJoins, createSelectJoins, formatJooqConditions, formatWhereContents, generateCorrelatedSubquery, generateForField, generateForField, generateForUnionField, generateHelperMethodName, generateNestedMethodName, generateSelectRow, getInitialKey, getInputConditions, getReturnType, getSelectCode, getSpecBuilder, inferFieldNamingConvention, isRoot, wrapInField, wrapInMultisetMethods inherited from class no.sikt.graphitron.generators.abstractions.DBMethodGenerator
getDefaultSpecBuilder, getDefaultSpecBuilderMethods inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
createServiceDependency, declareAllServiceClasses, declareAllServiceClasses, declareAllServiceClassesInAliasSet, getDataFetcherWiring, getDependencyMap, getLocalObject, getLocalTable, getTypeResolverWiringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface no.sikt.graphitron.generators.abstractions.MethodGenerator
generateAll
-
Constructor Details
-
NestedFetchDBMethodGenerator
-
-
Method Details
-
generate
- Specified by:
generatein classAbstractSchemaMethodGenerator<ObjectField,ObjectDefinition> - Returns:
- The complete javapoet
MethodSpecbased on the provided target.
-
generateNested
-
getHelperMethodCallForNestedField
protected no.sikt.graphitron.javapoet.CodeBlock getHelperMethodCallForNestedField(ObjectField field, FetchContext context) Description copied from class:FetchDBMethodGeneratorGenerates a helper method call for nested record type fields. This base implementation generates the root-level helper method call.- Overrides:
getHelperMethodCallForNestedFieldin classFetchDBMethodGenerator- Parameters:
field- The field to generate the helper method call forcontext- The fetch context (unused in base implementation)- Returns:
- CodeBlock containing the helper method call, or null to use inline generation
-