Class GenerateTableDaoClasses

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

public class GenerateTableDaoClasses extends Object
A utility class for generating data access Java beans using the metadata from a live database.
  • Constructor Details

    • GenerateTableDaoClasses

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

    • isMakeIdentifiersSingular

      public boolean isMakeIdentifiersSingular()
      Indicates if entity class names are made singular, such as Customer for a customers table (default false).
    • setMakeIdentifiersSingular

      public GenerateTableDaoClasses setMakeIdentifiersSingular(boolean makeIdentifiersSingular)
      Indicates if entity class names are made singular, such as Customer for a customers table (default false).
    • getEntitySuperClass

      public Class<?> getEntitySuperClass()
      Returns the superclass of the generated entities, or null for none; the fields, getters and setters it already declares are reused.
    • setEntitySuperClass

      public GenerateTableDaoClasses setEntitySuperClass(Class<?> entitySuperClass)
      Sets the superclass of the generated entities, or null for none; the fields, getters and setters it already declares are reused.
    • isExcludeCatalogAnnotation

      public boolean isExcludeCatalogAnnotation()
      Indicates if the catalog is left out of the generated @Table annotation (default false).
    • setExcludeCatalogAnnotation

      public GenerateTableDaoClasses setExcludeCatalogAnnotation(boolean excludeCatalogAnnotation)
      Indicates if the catalog is left out of the generated @Table annotation (default false).
    • isExcludeSchemaAnnotation

      public boolean isExcludeSchemaAnnotation()
      Indicates if the schema is left out of the generated @Table annotation (default false).
    • setExcludeSchemaAnnotation

      public GenerateTableDaoClasses setExcludeSchemaAnnotation(boolean excludeSchemaAnnotation)
      Indicates if the schema is left out of the generated @Table annotation (default false).
    • getExcludedTables

      public Set<String> getExcludedTables()
      Returns the names of the tables to skip, matched exactly against unqualified table names.
    • addExcludedTables

      public GenerateTableDaoClasses addExcludedTables(String... tables)
      Adds names of tables to skip, matched exactly against unqualified table names.
    • isSanitizeInput

      public boolean isSanitizeInput()
      Indicates if generated setters clean text values with the Jsoup basic whitelist to remove unsafe HTML (default false).
    • setSanitizeInput

      public GenerateTableDaoClasses setSanitizeInput(boolean sanitizeInput)
      Indicates if generated setters clean text values with the Jsoup basic whitelist to remove unsafe HTML (default false).
    • isIncludeTemplateMasterFormDef

      public boolean isIncludeTemplateMasterFormDef()
      Indicates if each generated entity includes a TemplateMaster FORM_DEF describing its columns (default false).
    • setIncludeTemplateMasterFormDef

      public GenerateTableDaoClasses setIncludeTemplateMasterFormDef(boolean includeTemplateMasterFormDef)
      Indicates if each generated entity includes a TemplateMaster FORM_DEF describing its columns (default false).
    • isUseDatabaseIdentifiersAsDisplayNames

      public boolean isUseDatabaseIdentifiersAsDisplayNames()
      Returns whether to use database identifiers as display names in generated form definitions.

      When true, the actual database column names are used as display names. When false (default), Java-style class names are used as display names.

      Returns:
      true if database identifiers should be used as display names, false otherwise
    • setUseDatabaseIdentifiersAsDisplayNames

      public GenerateTableDaoClasses setUseDatabaseIdentifiersAsDisplayNames(boolean useDatabaseIdentifiersAsDisplayNames)
      Sets whether to use database identifiers as display names in generated form definitions.

      When true, the actual database column names are used as display names. When false (default), Java-style class names are used as display names.

      Parameters:
      useDatabaseIdentifiersAsDisplayNames - true to use database identifiers as display names, false otherwise
      Returns:
      this instance for method chaining
    • generate

      public void generate(String catalog, String schemaPattern, String tableNamePattern, String... types)
      Generates a data access class for each non-excluded table matching the given DatabaseMetaData.getTables arguments; when writing files, code below the custom code marker comment of an existing file is kept.
    • createTableConfig

      protected GenerateTableDaoClasses.TableConfig createTableConfig(JdbcTable table)
      Creates the class name, package and file settings used to generate a table's class; override to change them per table.
    • addImports

      protected void addImports(JavaCodeBuilder code, boolean serializable, boolean recordSerializable, List<String> implementsList)
      Adds a generated class's imports, and the interfaces it implements to implementsList; the flags tell if the superclass is already Serializable or RecordSerializable.
    • getPrintWriter

      public PrintWriter getPrintWriter()
      Returns the writer that receives the generated source when not writing files (standard output if not set).
    • setPrintWriter

      public GenerateTableDaoClasses setPrintWriter(PrintWriter printWriter)
      Sets the writer that receives the generated source when not writing files (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 GenerateTableDaoClasses setWriteToFile(boolean writeToFile)
      Indicates if generated classes are written as files under the base folder instead of printed to the print writer (default true).