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 EntityTypecreateEntityType(SchemaAndTable schemaAndTable, String className) protected PropertycreateProperty(EntityType classModel, String normalizedColumnName, String propertyName, com.querydsl.codegen.utils.model.Type typeModel) voidExport the tables based on the given database metadatavoidsetBeanPackageName(@Nullable String beanPackageName) Override the bean package name (default: packageName)voidsetBeanPrefix(String beanPrefix) Override the bean prefix for the classes (default: "")voidsetBeanSerializer(@Nullable Serializer beanSerializer) Set the Bean serializer to create bean types as wellvoidsetBeanSerializerClass(Class<? extends Serializer> beanSerializerClass) Set the Bean serializer class to create bean types as wellvoidsetBeansTargetFolder(File targetFolder) Set the target folder for beansvoidsetBeanSuffix(String beanSuffix) Override the bean suffix for the classes (default: "")voidsetCatalogPattern(@Nullable String catalogPattern) a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog;nullmeans that the catalog name should not be used to narrow the searchvoidsetColumnAnnotations(boolean columnAnnotations) Set whether column annotations should be createdvoidsetColumnComparatorClass(Class<? extends Comparator<Property>> columnComparatorClass) Set the column comparator classvoidsetConfiguration(Configuration configuration) Override the configurationvoidsetCreateScalaSources(boolean createScalaSources) Set true to create Scala sources instead of Java sourcesvoidsetExportAll(boolean exportAll) Set whether all table types should be exportedvoidsetExportDirectForeignKeys(boolean exportDirectForeignKeys) Set whether direct foreign keys should be exportedvoidsetExportForeignKeys(boolean exportForeignKeys) Set whether foreign keys should be exportedvoidsetExportInverseForeignKeys(boolean exportInverseForeignKeys) Set whether inverse foreign keys should be exportedvoidsetExportPrimaryKeys(boolean exportPrimaryKeys) Set whether primary keys should be exportedvoidsetExportTables(boolean exportTables) Set whether tables should be exportedvoidsetExportViews(boolean exportViews) Set whether views should be exportedvoidsetGeneratedAnnotationClass(@Nullable String generatedAnnotationClass) Set the fully qualified class name of the "generated" annotation added ot the generated sourcesvoidsetImports(String[] imports) Set the java importsvoidsetInnerClassesForKeys(boolean innerClassesForKeys) Set whether inner classes should be created for keysvoidsetLowerCase(boolean lowerCase) Set whether names should be normalized to lowercasevoidsetNamePrefix(String namePrefix) Override the name prefix for the classes (default: Q)voidsetNameSuffix(String nameSuffix) Override the name suffix for the classes (default: "")voidsetNamingStrategy(NamingStrategy namingStrategy) Override the NamingStrategy (default: new DefaultNamingStrategy())voidsetPackageName(String packageName) Set the package namevoidsetSchemaPattern(@Nullable String schemaPattern) Set the schema pattern filter to be usedvoidsetSchemaToPackage(boolean schemaToPackage) Deprecated.voidsetSerializerClass(Class<? extends Serializer> serializerClass) Set the serializer classvoidsetSourceEncoding(String sourceEncoding) Set the source encodingvoidsetSpatial(boolean spatial) Set whether spatial type support should be usedvoidsetTableNamePattern(@Nullable String tableNamePattern) Set the table name pattern filter to be usedvoidsetTableTypesToExport(String tableTypesToExport) Set the table types to export as a comma separated stringvoidsetTargetFolder(File targetFolder) Set the target foldervoidsetTypeMappings(TypeMappings typeMappings) Set the type mappings to usevoidsetValidationAnnotations(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;nullmeans 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;nullmeans 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 ifschemaToPackageis 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 (withStringelement) to be used on the generated sources, ornull(defaulting tojavax.annotation.Generatedorjavax.annotation.processing.Generateddepending on the java version).- See Also:
-
NamingStrategy.getPackage(String, SchemaAndTable).