Class DefaultJpqlRepairer

java.lang.Object
io.jmix.aitools.dataload.repair.impl.DefaultJpqlRepairer
All Implemented Interfaces:
JpqlRepairer, org.springframework.beans.factory.InitializingBean

public class DefaultJpqlRepairer extends Object implements JpqlRepairer, org.springframework.beans.factory.InitializingBean
Default JpqlRepairer that re-prompts the LLM with the previous query and its validation issues, then parses the corrected JPQL from the model's JSON reply.
  • Field Details

    • jpqlRepairerPromptProvider

      @Autowired protected JpqlRepairerPromptProvider jpqlRepairerPromptProvider
    • chatClientFactory

      @Autowired protected ChatClientFactory chatClientFactory
    • objectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
  • Constructor Details

    • DefaultJpqlRepairer

      public DefaultJpqlRepairer()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Initializes the JSON object mapper after the bean is created.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • repair

      @NullMarked public GeneratedJpqlResult repair(JpqlRepairRequest request)
      Description copied from interface: JpqlRepairer
      Attempts to repair the invalid query described by the request.
      Specified by:
      repair in interface JpqlRepairer
      Parameters:
      request - repair request with the current query
      Returns:
      query draft, or null if no repaired result could be produced
    • formatValidationIssues

      protected String formatValidationIssues(List<JpqlValidationIssue> issues)
    • formatRepairGuidance

      protected String formatRepairGuidance(List<JpqlValidationIssue> issues)
    • executePrompt

      protected GeneratedJpqlResult executePrompt(JpqlRepairRequest request)
    • readPromptTemplate

      protected String readPromptTemplate()
    • mapToGeneratedJpqlResult

      protected GeneratedJpqlResult mapToGeneratedJpqlResult(GeneratedJpqlPayload payload)
    • toGeneratedJpqlParameter

      protected @Nullable GeneratedJpqlParameter toGeneratedJpqlParameter(GeneratedJpqlParameterPayload payload)
      Maps a parameter payload to a GeneratedJpqlParameter, or returns null to skip it when the model provided no parameter name (such a parameter cannot be bound).
      Parameters:
      payload - raw parameter payload from the model
      Returns:
      mapped parameter, or null if it has no usable name
    • createObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper createObjectMapper()
    • toJson

      protected String toJson(Object object)