Class GenerateQueryDaoClasses

java.lang.Object
com.northconcepts.datapipeline.foundations.tools.GenerateQueryDaoClasses

public class GenerateQueryDaoClasses extends Object
Generates a class for each query registered with a JdbcConnection, with a field per result column and static executeQuery methods. Each query is run with its example parameter values to discover its columns.
  • Constructor Details

    • GenerateQueryDaoClasses

      public GenerateQueryDaoClasses(JdbcConnection jdbcConnection, File baseFolder, String targetPackage)
  • Method Details

    • isMakeIdentifiersSingular

      public boolean isMakeIdentifiersSingular()
    • setMakeIdentifiersSingular

      public GenerateQueryDaoClasses setMakeIdentifiersSingular(boolean makeIdentifiersSingular)
    • getEntitySuperClass

      public Class<?> getEntitySuperClass()
      Returns the superclass of the generated classes, or null for none; generated record serialization also calls a RecordSerializable superclass.
    • setEntitySuperClass

      public GenerateQueryDaoClasses setEntitySuperClass(Class<?> entitySuperClass)
      Sets the superclass of the generated classes, or null for none; generated record serialization also calls a RecordSerializable superclass.
    • generate

      public void generate()
      Runs each query registered with the connection and generates its class, writing a file or printing it per isWriteToFile().
    • getEntityFile

      public File getEntityFile(String fileName)
      Returns the .java file for the given class name in the target package's folder under the base folder.
    • getFieldAsJavaIdentifierName

      public String getFieldAsJavaIdentifierName(JavaCodeBuilder code, JdbcQueryColumn column, int index)
      Returns the unique Java field name for the query column at the given index of the class being generated, creating it on first use.
    • getPrintWriter

      public PrintWriter getPrintWriter()
      Returns the writer for progress messages and, when not writing files, the generated source (standard output if not set).
    • setPrintWriter

      public GenerateQueryDaoClasses setPrintWriter(PrintWriter printWriter)
      Sets the writer for progress messages and, when not writing files, the generated source (standard output if not set).
    • isWriteToFile

      public boolean isWriteToFile()
      Indicates if generated classes are written as files under the base folder instead of printed to the print writer (default true).
    • setWriteToFile

      public GenerateQueryDaoClasses setWriteToFile(boolean writeToFile)
      Indicates if generated classes are written as files under the base folder instead of printed to the print writer (default true).
    • getJavaCode

      public List<String> getJavaCode()
      Returns the source of each class generated by the last generate() call, or null before the first call.