Goal: CREATE

hibernate:create

Full name:

de.juplo:hibernate-maven-plugin:2.0.0:create

Description:

Goal which extracts the hibernate-mapping-configuration and exports an according SQL-database-schema.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • The goal is thread-safe and supports parallel builds.
  • Binds by default to the lifecycle phase: process-classes.

Optional Parameters

Name Type Since Description
createNamespaces Boolean 2.0 Specifies whether to automatically create also the database schema/catalog.
Default value is: false.
User property is: hibernate.hbm2dll.create_namespaces.
delimiter String 1.0 Delimiter in output-file.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


Default value is: ;.
User property is: hibernate.schema.delimiter.
dialect String 1.0 Hibernate dialect.
User property is: hibernate.dialect.
driver String 1.0 SQL-Driver name.
User property is: hibernate.connection.driver_class.
export Boolean 2.0 Export the database-schma to the database. If set to false, only the SQL-script is created and the database is not touched.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


Default value is: true.
User property is: hibernate.schema.export.
force boolean 1.0 Force execution

Force execution, even if no modified or newly added annotated classes where found and the dialect was not changed.

skip takes precedence over force.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


Default value is: false.
User property is: hibernate.schema.force.
format Boolean 1.0 Format output-file.
User property is: hibernate.format_sql.
hibernateConfig String 1.1.0 Path to Hibernate configuration file (.cfg.xml). If this parameter is specified, the plugin will try to load configuration values from a file with the given path or a ressource on the classpath with the given name. If both fails, the execution of the plugin will fail.

If this parameter is not set the plugin will load configuration values from a ressource named hibernate.cfg.xml on the classpath, if it is present, but will not fail if there is no such ressource.

During ressource-lookup, the test-classpath takes precedence.

Settings in this file will overwrite settings in the properties file.


hibernateProperties String 1.0 Path to a file or name of a ressource with hibernate properties. If this parameter is specified, the plugin will try to load configuration values from a file with the given path or a ressource on the classpath with the given name. If both fails, the execution of the plugin will fail.

If this parameter is not set the plugin will load configuration values from a ressource named hibernate.properties on the classpath, if it is present, but will not fail if there is no such ressource.

During ressource-lookup, the test-classpath takes precedence.


implicitNamingStrategy String 2.0 Implicit naming strategy
User property is: hibernate.implicit_naming_strategy.
mappings String 1.0.2 List of Hibernate-Mapping-Files (XML). Multiple files can be separated with white-spaces and/or commas.
User property is: hibernate.mapping.
outputDirectory String 1.0 Classes-Directory to scan.

This parameter defaults to the maven build-output-directory for classes. Additionally, all dependencies are scanned for annotated classes.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


User property is: project.build.outputDirectory.
outputFile String 1.0 Output file.

If the specified filename is not absolut, the file will be created relative to the project build directory (project.build.directory).


Default value is: create.sql.
User property is: hibernate.schema.export.create.
password String 1.0 Database password
User property is: hibernate.connection.password.
persistenceUnit String 1.1.0 Name of the persistence-unit. If this parameter is specified, the plugin will try to load configuration values from a persistence-unit with the specified name. If no such persistence-unit can be found, the plugin will throw an exception.

If this parameter is not set and there is only one persistence-unit available, that unit will be used automatically. But if this parameter is not set and there are multiple persistence-units available on, the class-path, the execution of the plugin will fail.

Settings in this file will overwrite settings in the properties or the configuration file.


physicalNamingStrategy String 2.0 Physical naming strategy
User property is: hibernate.physical_naming_strategy.
scanClasses Boolean 2.0 Wether the project should be scanned for annotated-classes, or not

This parameter is intended to allow overwriting of the parameter exclude-unlisted-classes of a persistence-unit. If not specified, it defaults to true


User property is: hibernate.schema.scan.classes.
scanDependencies String 1.0.3 Dependency-Scopes, that should be scanned for annotated classes.

By default, only dependencies in the scope compile are scanned for annotated classes. Multiple scopes can be seperated by white space or commas.

If you do not want any dependencies to be scanned for annotated classes, set this parameter to none.

The plugin does not scan for annotated classes in transitive dependencies. If some of your annotated classes are hidden in a transitive dependency, you can simply add that dependency explicitly.


Default value is: compile.
User property is: hibernate.schema.scan.dependencies.
scanTestClasses Boolean 1.0.1 Whether to scan the test-branch of the project for annotated classes, or not.

If this parameter is set to true the test-classes of the artifact will be scanned for hibernate-annotated classes additionally.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


Default value is: false.
User property is: hibernate.schema.scan.test_classes.
show Boolean 1.0 Show the generated SQL in the command-line output.
User property is: hibernate.show_sql.
skip boolean 1.0 Skip execution

If set to true, the execution is skipped.

A skipped execution is signaled via the maven-property ${hibernate.schema.skipped}.

The execution is skipped automatically, if no modified or newly added annotated classes are found and the dialect was not changed.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


Default value is: ${maven.test.skip}.
User property is: hibernate.schema.skip.
testOutputDirectory String 1.0.2 Test-Classes-Directory to scan.

This parameter defaults to the maven build-output-directory for test-classes.

This parameter is only used, when scanTestClasses is set to true!

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!


User property is: project.build.testOutputDirectory.
url String 1.0 Database URL.
User property is: hibernate.connection.url.
username String 1.0 Database username
User property is: hibernate.connection.username.

Parameter Details

createNamespaces:

Specifies whether to automatically create also the database schema/catalog.
  • Type: java.lang.Boolean
  • Since: 2.0
  • Required: No
  • User Property: hibernate.hbm2dll.create_namespaces
  • Default: false

delimiter:

Delimiter in output-file.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.schema.delimiter
  • Default: ;

dialect:

Hibernate dialect.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.dialect

driver:

SQL-Driver name.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.connection.driver_class

export:

Export the database-schma to the database. If set to false, only the SQL-script is created and the database is not touched.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: java.lang.Boolean
  • Since: 2.0
  • Required: No
  • User Property: hibernate.schema.export
  • Default: true

force:

Force execution

Force execution, even if no modified or newly added annotated classes where found and the dialect was not changed.

skip takes precedence over force.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: boolean
  • Since: 1.0
  • Required: No
  • User Property: hibernate.schema.force
  • Default: false

format:

Format output-file.
  • Type: java.lang.Boolean
  • Since: 1.0
  • Required: No
  • User Property: hibernate.format_sql

hibernateConfig:

Path to Hibernate configuration file (.cfg.xml). If this parameter is specified, the plugin will try to load configuration values from a file with the given path or a ressource on the classpath with the given name. If both fails, the execution of the plugin will fail.

If this parameter is not set the plugin will load configuration values from a ressource named hibernate.cfg.xml on the classpath, if it is present, but will not fail if there is no such ressource.

During ressource-lookup, the test-classpath takes precedence.

Settings in this file will overwrite settings in the properties file.

  • Type: java.lang.String
  • Since: 1.1.0
  • Required: No

hibernateProperties:

Path to a file or name of a ressource with hibernate properties. If this parameter is specified, the plugin will try to load configuration values from a file with the given path or a ressource on the classpath with the given name. If both fails, the execution of the plugin will fail.

If this parameter is not set the plugin will load configuration values from a ressource named hibernate.properties on the classpath, if it is present, but will not fail if there is no such ressource.

During ressource-lookup, the test-classpath takes precedence.

  • Type: java.lang.String
  • Since: 1.0
  • Required: No

implicitNamingStrategy:

Implicit naming strategy
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: hibernate.implicit_naming_strategy

mappings:

List of Hibernate-Mapping-Files (XML). Multiple files can be separated with white-spaces and/or commas.
  • Type: java.lang.String
  • Since: 1.0.2
  • Required: No
  • User Property: hibernate.mapping

outputDirectory:

Classes-Directory to scan.

This parameter defaults to the maven build-output-directory for classes. Additionally, all dependencies are scanned for annotated classes.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: project.build.outputDirectory

outputFile:

Output file.

If the specified filename is not absolut, the file will be created relative to the project build directory (project.build.directory).

  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.schema.export.create
  • Default: create.sql

password:

Database password
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.connection.password

persistenceUnit:

Name of the persistence-unit. If this parameter is specified, the plugin will try to load configuration values from a persistence-unit with the specified name. If no such persistence-unit can be found, the plugin will throw an exception.

If this parameter is not set and there is only one persistence-unit available, that unit will be used automatically. But if this parameter is not set and there are multiple persistence-units available on, the class-path, the execution of the plugin will fail.

Settings in this file will overwrite settings in the properties or the configuration file.

  • Type: java.lang.String
  • Since: 1.1.0
  • Required: No

physicalNamingStrategy:

Physical naming strategy
  • Type: java.lang.String
  • Since: 2.0
  • Required: No
  • User Property: hibernate.physical_naming_strategy

scanClasses:

Wether the project should be scanned for annotated-classes, or not

This parameter is intended to allow overwriting of the parameter exclude-unlisted-classes of a persistence-unit. If not specified, it defaults to true

  • Type: java.lang.Boolean
  • Since: 2.0
  • Required: No
  • User Property: hibernate.schema.scan.classes

scanDependencies:

Dependency-Scopes, that should be scanned for annotated classes.

By default, only dependencies in the scope compile are scanned for annotated classes. Multiple scopes can be seperated by white space or commas.

If you do not want any dependencies to be scanned for annotated classes, set this parameter to none.

The plugin does not scan for annotated classes in transitive dependencies. If some of your annotated classes are hidden in a transitive dependency, you can simply add that dependency explicitly.

  • Type: java.lang.String
  • Since: 1.0.3
  • Required: No
  • User Property: hibernate.schema.scan.dependencies
  • Default: compile

scanTestClasses:

Whether to scan the test-branch of the project for annotated classes, or not.

If this parameter is set to true the test-classes of the artifact will be scanned for hibernate-annotated classes additionally.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: java.lang.Boolean
  • Since: 1.0.1
  • Required: No
  • User Property: hibernate.schema.scan.test_classes
  • Default: false

show:

Show the generated SQL in the command-line output.
  • Type: java.lang.Boolean
  • Since: 1.0
  • Required: No
  • User Property: hibernate.show_sql

skip:

Skip execution

If set to true, the execution is skipped.

A skipped execution is signaled via the maven-property ${hibernate.schema.skipped}.

The execution is skipped automatically, if no modified or newly added annotated classes are found and the dialect was not changed.

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: boolean
  • Since: 1.0
  • Required: No
  • User Property: hibernate.schema.skip
  • Default: ${maven.test.skip}

testOutputDirectory:

Test-Classes-Directory to scan.

This parameter defaults to the maven build-output-directory for test-classes.

This parameter is only used, when scanTestClasses is set to true!

Important: This configuration value can only be configured through the pom.xml, or by the definition of a system-property, because it is not known by Hibernate nor JPA and, hence, not picked up from their configuration!

  • Type: java.lang.String
  • Since: 1.0.2
  • Required: No
  • User Property: project.build.testOutputDirectory

url:

Database URL.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.connection.url

username:

Database username
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: hibernate.connection.username