Class MetaDataExporter

java.lang.Object
com.querydsl.sql.codegen.MetaDataExporter

public class MetaDataExporter extends Object
MetadataExporter exports JDBC metadata to Querydsl query types

Example

 MetaDataExporter exporter = new MetaDataExporter();
 exporter.setPackageName("com.example.domain");
 exporter.setTargetFolder(new File("target/generated-sources/java"));
 exporter.export(connection.getMetaData());
 
Author:
tiwe
  • Constructor Details

    • MetaDataExporter

      public MetaDataExporter()
  • Method Details

    • createEntityType

      protected EntityType createEntityType(SchemaAndTable schemaAndTable, String className)
    • createProperty

      protected Property createProperty(EntityType classModel, String normalizedColumnName, String propertyName, com.querydsl.codegen.utils.model.Type typeModel)
    • export

      public void export(DatabaseMetaData md) throws SQLException
      Export the tables based on the given database metadata
      Parameters:
      md - database metadata
      Throws:
      SQLException
    • setSchemaPattern

      public void setSchemaPattern(@Nullable @Nullable String schemaPattern)
      Set the schema pattern filter to be used
      Parameters:
      schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search (default: null)
    • setCatalogPattern

      public void setCatalogPattern(@Nullable @Nullable String catalogPattern)
      a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
    • setTableNamePattern

      public void setTableNamePattern(@Nullable @Nullable String tableNamePattern)
      Set the table name pattern filter to be used
      Parameters:
      tableNamePattern - a table name pattern; must match the table name as it is stored in the database (default: null)
    • setConfiguration

      public void setConfiguration(Configuration configuration)
      Override the configuration
      Parameters:
      configuration - override configuration for custom type mappings etc
    • setCreateScalaSources

      public void setCreateScalaSources(boolean createScalaSources)
      Set true to create Scala sources instead of Java sources
      Parameters:
      createScalaSources - whether to create Scala sources (default: false)
    • setTargetFolder

      public void setTargetFolder(File targetFolder)
      Set the target folder
      Parameters:
      targetFolder - target source folder to create the sources into (e.g. target/generated-sources/java)
    • setBeansTargetFolder

      public void setBeansTargetFolder(File targetFolder)
      Set the target folder for beans

      defaults to the targetFolder value

      Parameters:
      targetFolder - target source folder to create the bean sources into
    • setPackageName

      public void setPackageName(String packageName)
      Set the package name
      Parameters:
      packageName - package name for sources
    • setBeanPackageName

      public void setBeanPackageName(@Nullable @Nullable String beanPackageName)
      Override the bean package name (default: packageName)
      Parameters:
      beanPackageName - package name for bean sources
    • setNamePrefix

      public void setNamePrefix(String namePrefix)
      Override the name prefix for the classes (default: Q)
      Parameters:
      namePrefix - name prefix for querydsl-types (default: Q)
    • setNameSuffix

      public void setNameSuffix(String nameSuffix)
      Override the name suffix for the classes (default: "")
      Parameters:
      nameSuffix - name suffix for querydsl-types (default: "")
    • setBeanPrefix

      public void setBeanPrefix(String beanPrefix)
      Override the bean prefix for the classes (default: "")
      Parameters:
      beanPrefix - bean prefix for bean-types (default: "")
    • setBeanSuffix

      public void setBeanSuffix(String beanSuffix)
      Override the bean suffix for the classes (default: "")
      Parameters:
      beanSuffix - bean suffix for bean-types (default: "")
    • setNamingStrategy

      public void setNamingStrategy(NamingStrategy namingStrategy)
      Override the NamingStrategy (default: new DefaultNamingStrategy())
      Parameters:
      namingStrategy - naming strategy to override (default: new DefaultNamingStrategy())
    • setBeanSerializer

      public void setBeanSerializer(@Nullable @Nullable Serializer beanSerializer)
      Set the Bean serializer to create bean types as well
      Parameters:
      beanSerializer - serializer for JavaBeans (default: null)
    • setBeanSerializerClass

      public void setBeanSerializerClass(Class<? extends Serializer> beanSerializerClass)
      Set the Bean serializer class to create bean types as well
      Parameters:
      beanSerializerClass - serializer for JavaBeans (default: null)
    • setInnerClassesForKeys

      public void setInnerClassesForKeys(boolean innerClassesForKeys)
      Set whether inner classes should be created for keys
      Parameters:
      innerClassesForKeys -
    • setColumnComparatorClass

      public void setColumnComparatorClass(Class<? extends Comparator<Property>> columnComparatorClass)
      Set the column comparator class
      Parameters:
      columnComparatorClass -
    • setSerializerClass

      public void setSerializerClass(Class<? extends Serializer> serializerClass)
      Set the serializer class
      Parameters:
      serializerClass -
    • setTypeMappings

      public void setTypeMappings(TypeMappings typeMappings)
      Set the type mappings to use
      Parameters:
      typeMappings -
    • setColumnAnnotations

      public void setColumnAnnotations(boolean columnAnnotations)
      Set whether column annotations should be created
      Parameters:
      columnAnnotations -
    • setValidationAnnotations

      public void setValidationAnnotations(boolean validationAnnotations)
      Set whether validation annotations should be created
      Parameters:
      validationAnnotations -
    • setSourceEncoding

      public void setSourceEncoding(String sourceEncoding)
      Set the source encoding
      Parameters:
      sourceEncoding -
    • setSchemaToPackage

      @Deprecated public void setSchemaToPackage(boolean schemaToPackage)
      Deprecated.
      This flag will not be necessary in the future because the generated package name can be controlled in method NamingStrategy.getPackage(String, SchemaAndTable).
      Set whether schema names should be appended to the package name.

      !!! Important !!! NamingStrategy.getPackage(String, SchemaAndTable) will be invoked only if schemaToPackage is set to true.

      Parameters:
      schemaToPackage -
    • setLowerCase

      public void setLowerCase(boolean lowerCase)
      Set whether names should be normalized to lowercase
      Parameters:
      lowerCase -
    • setExportTables

      public void setExportTables(boolean exportTables)
      Set whether tables should be exported
      Parameters:
      exportTables -
    • setExportViews

      public void setExportViews(boolean exportViews)
      Set whether views should be exported
      Parameters:
      exportViews -
    • setExportAll

      public void setExportAll(boolean exportAll)
      Set whether all table types should be exported
      Parameters:
      exportAll -
    • setExportPrimaryKeys

      public void setExportPrimaryKeys(boolean exportPrimaryKeys)
      Set whether primary keys should be exported
      Parameters:
      exportPrimaryKeys -
    • setExportForeignKeys

      public void setExportForeignKeys(boolean exportForeignKeys)
      Set whether foreign keys should be exported
      Parameters:
      exportForeignKeys -
    • setExportDirectForeignKeys

      public void setExportDirectForeignKeys(boolean exportDirectForeignKeys)
      Set whether direct foreign keys should be exported
      Parameters:
      exportDirectForeignKeys -
    • setExportInverseForeignKeys

      public void setExportInverseForeignKeys(boolean exportInverseForeignKeys)
      Set whether inverse foreign keys should be exported
      Parameters:
      exportInverseForeignKeys -
    • setImports

      public void setImports(String[] imports)
      Set the java imports
      Parameters:
      imports - java imports array
    • setSpatial

      public void setSpatial(boolean spatial)
      Set whether spatial type support should be used
      Parameters:
      spatial -
    • setTableTypesToExport

      public void setTableTypesToExport(String tableTypesToExport)
      Set the table types to export as a comma separated string
      Parameters:
      tableTypesToExport -
    • setGeneratedAnnotationClass

      public void setGeneratedAnnotationClass(@Nullable @Nullable String generatedAnnotationClass)
      Set the fully qualified class name of the "generated" annotation added ot the generated sources
      Parameters:
      generatedAnnotationClass - the fully qualified class name of the Single-Element Annotation (with String element) to be used on the generated sources, or null (defaulting to javax.annotation.Generated or javax.annotation.processing.Generated depending on the java version).
      See Also: