Package com.querydsl.sql.codegen
Class MetaDataExporter
java.lang.Object
com.querydsl.sql.codegen.MetaDataExporter
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected EntityType
createEntityType
(SchemaAndTable schemaAndTable, String className) protected Property
createProperty
(EntityType classModel, String normalizedColumnName, String propertyName, com.querydsl.codegen.utils.model.Type typeModel) void
Export the tables based on the given database metadatavoid
setBeanPackageName
(@Nullable String beanPackageName) Override the bean package name (default: packageName)void
setBeanPrefix
(String beanPrefix) Override the bean prefix for the classes (default: "")void
setBeanSerializer
(@Nullable Serializer beanSerializer) Set the Bean serializer to create bean types as wellvoid
setBeanSerializerClass
(Class<? extends Serializer> beanSerializerClass) Set the Bean serializer class to create bean types as wellvoid
setBeansTargetFolder
(File targetFolder) Set the target folder for beansvoid
setBeanSuffix
(String beanSuffix) Override the bean suffix for the classes (default: "")void
setCatalogPattern
(@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 searchvoid
setColumnAnnotations
(boolean columnAnnotations) Set whether column annotations should be createdvoid
setColumnComparatorClass
(Class<? extends Comparator<Property>> columnComparatorClass) Set the column comparator classvoid
setConfiguration
(Configuration configuration) Override the configurationvoid
setCreateScalaSources
(boolean createScalaSources) Set true to create Scala sources instead of Java sourcesvoid
setExportAll
(boolean exportAll) Set whether all table types should be exportedvoid
setExportDirectForeignKeys
(boolean exportDirectForeignKeys) Set whether direct foreign keys should be exportedvoid
setExportForeignKeys
(boolean exportForeignKeys) Set whether foreign keys should be exportedvoid
setExportInverseForeignKeys
(boolean exportInverseForeignKeys) Set whether inverse foreign keys should be exportedvoid
setExportPrimaryKeys
(boolean exportPrimaryKeys) Set whether primary keys should be exportedvoid
setExportTables
(boolean exportTables) Set whether tables should be exportedvoid
setExportViews
(boolean exportViews) Set whether views should be exportedvoid
setGeneratedAnnotationClass
(@Nullable String generatedAnnotationClass) Set the fully qualified class name of the "generated" annotation added ot the generated sourcesvoid
setImports
(String[] imports) Set the java importsvoid
setInnerClassesForKeys
(boolean innerClassesForKeys) Set whether inner classes should be created for keysvoid
setLowerCase
(boolean lowerCase) Set whether names should be normalized to lowercasevoid
setNamePrefix
(String namePrefix) Override the name prefix for the classes (default: Q)void
setNameSuffix
(String nameSuffix) Override the name suffix for the classes (default: "")void
setNamingStrategy
(NamingStrategy namingStrategy) Override the NamingStrategy (default: new DefaultNamingStrategy())void
setPackageName
(String packageName) Set the package namevoid
setSchemaPattern
(@Nullable String schemaPattern) Set the schema pattern filter to be usedvoid
setSchemaToPackage
(boolean schemaToPackage) Deprecated.void
setSerializerClass
(Class<? extends Serializer> serializerClass) Set the serializer classvoid
setSourceEncoding
(String sourceEncoding) Set the source encodingvoid
setSpatial
(boolean spatial) Set whether spatial type support should be usedvoid
setTableNamePattern
(@Nullable String tableNamePattern) Set the table name pattern filter to be usedvoid
setTableTypesToExport
(String tableTypesToExport) Set the table types to export as a comma separated stringvoid
setTargetFolder
(File targetFolder) Set the target foldervoid
setTypeMappings
(TypeMappings typeMappings) Set the type mappings to usevoid
setValidationAnnotations
(boolean validationAnnotations) Set whether validation annotations should be created
-
Constructor Details
-
MetaDataExporter
public MetaDataExporter()
-
-
Method Details
-
createEntityType
-
createProperty
protected Property createProperty(EntityType classModel, String normalizedColumnName, String propertyName, com.querydsl.codegen.utils.model.Type typeModel) -
export
Export the tables based on the given database metadata- Parameters:
md
- database metadata- Throws:
SQLException
-
setSchemaPattern
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
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
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
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
Set the target folder- Parameters:
targetFolder
- target source folder to create the sources into (e.g. target/generated-sources/java)
-
setBeansTargetFolder
Set the target folder for beansdefaults to the targetFolder value
- Parameters:
targetFolder
- target source folder to create the bean sources into
-
setPackageName
Set the package name- Parameters:
packageName
- package name for sources
-
setBeanPackageName
Override the bean package name (default: packageName)- Parameters:
beanPackageName
- package name for bean sources
-
setNamePrefix
Override the name prefix for the classes (default: Q)- Parameters:
namePrefix
- name prefix for querydsl-types (default: Q)
-
setNameSuffix
Override the name suffix for the classes (default: "")- Parameters:
nameSuffix
- name suffix for querydsl-types (default: "")
-
setBeanPrefix
Override the bean prefix for the classes (default: "")- Parameters:
beanPrefix
- bean prefix for bean-types (default: "")
-
setBeanSuffix
Override the bean suffix for the classes (default: "")- Parameters:
beanSuffix
- bean suffix for bean-types (default: "")
-
setNamingStrategy
Override the NamingStrategy (default: new DefaultNamingStrategy())- Parameters:
namingStrategy
- naming strategy to override (default: new DefaultNamingStrategy())
-
setBeanSerializer
Set the Bean serializer to create bean types as well- Parameters:
beanSerializer
- serializer for JavaBeans (default: null)
-
setBeanSerializerClass
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
Set the column comparator class- Parameters:
columnComparatorClass
-
-
setSerializerClass
Set the serializer class- Parameters:
serializerClass
-
-
setTypeMappings
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
Set the source encoding- Parameters:
sourceEncoding
-
-
setSchemaToPackage
Deprecated.This flag will not be necessary in the future because the generated package name can be controlled in methodNamingStrategy.getPackage(String, SchemaAndTable)
.Set whether schema names should be appended to the package name.!!! Important !!!
NamingStrategy.getPackage(String, SchemaAndTable)
will be invoked only ifschemaToPackage
is set totrue
.- 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
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
Set the table types to export as a comma separated string- Parameters:
tableTypesToExport
-
-
setGeneratedAnnotationClass
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 (withString
element) to be used on the generated sources, ornull
(defaulting tojavax.annotation.Generated
orjavax.annotation.processing.Generated
depending on the java version).- See Also:
-
NamingStrategy.getPackage(String, SchemaAndTable)
.