Package no.sikt.graphitron.generators.db
Class NestedFetchDBMethodGenerator
java.lang.Object
no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator<T,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:
FetchMappedObjectDBMethodGenerator,FetchNodeImplementationDBMethodGenerator
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.-
Field Summary
Fields inherited from class no.sikt.graphitron.generators.db.FetchDBMethodGenerator
conditionsShouldFallbackToFalse, ELEMENT_NAME, isRoot, resolverKeyParamNameFields inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
dependencyMap, localObject, processedSchema -
Constructor Summary
ConstructorsConstructorDescriptionNestedFetchDBMethodGenerator(ObjectDefinition localObject, ProcessedSchema processedSchema) -
Method Summary
Modifier and TypeMethodDescriptionprotected no.sikt.graphitron.javapoet.CodeBlockgetHelperMethodCallForNestedField(ObjectField field, FetchContext context) Override this method to provide a helper method call for nested record type fields.Methods inherited from class no.sikt.graphitron.generators.db.FetchDBMethodGenerator
createAliasDeclarations, createAliasDeclarations, createMapping, createOrderFieldsBlock, createOrderFieldsDeclarationBlock, createSeekAndLimitBlock, createSelectConditions, createSelectJoins, createSelectJoins, formatJooqConditions, formatWhereContents, generateCorrelatedSubquery, generateForField, generateForField, generateForUnionField, generateSelectRow, getInitialKey, getInputConditions, getSelectCodeAndFieldSource, getSpecBuilder, inferFieldNamingConvention, wrapInField, wrapInMultisetMethods inherited from class no.sikt.graphitron.generators.abstractions.DBMethodGenerator
getDefaultSpecBuilderMethods inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
createServiceDependency, declareAllServiceClasses, declareAllServiceClasses, declareAllServiceClassesInAliasSet, generate, 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
-
getHelperMethodCallForNestedField
protected no.sikt.graphitron.javapoet.CodeBlock getHelperMethodCallForNestedField(ObjectField field, FetchContext context) Description copied from class:FetchDBMethodGeneratorOverride this method to provide a helper method call for nested record type fields. Return null to use inline generation.- Overrides:
getHelperMethodCallForNestedFieldin classFetchDBMethodGenerator
-