]> juplo.de Git - website/blob
109e6c9af493b17e75fc5436704887f54fffd6de
[website] /
1 ---
2 _edit_last: "1"
3 author: kai
4 categories:
5   - hibernate
6   - java
7   - maven
8 date: "2020-06-15T19:15:58+00:00"
9 guid: http://juplo.de/?p=34
10 parent_post_id: null
11 post_id: "34"
12 title: hibernate4-maven-plugin
13 url: /hibernate4-maven-plugin-a-simple-plugin-for-generating-a-database-schema-from-hibernate-4-mapping-annotations/
14
15 ---
16 ## A simple Plugin for generating a Database-Schema from Hibernate 4 Mapping-Annotations
17
18 Hibernate comes with the buildin functionality, to automatically create or update the database schema. This functionality is configured in the session-configuraton via the parameter `hbm2ddl.auto` (see [Hibernate Reference Documentation - Chapter 3.4. Optional configuration properties](http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-optional)). But doing so [is not very wise](http://stackoverflow.com/questions/221379/hibernate-hbm2ddl-auto-update-in-production), because you can easily corrupt or erase your production database, if this configuration parameter slips through to your production environment.
19
20 Alternatively, you can [run the tools **SchemaExport** or **SchemaUpdate** by hand](http://stackoverflow.com/questions/835961/how-to-creata-database-schema-using-hibernate). But that is not very comfortable and being used to maven you will quickly long for a plugin, that does that job automatically for you, when you fire up your test cases.
21
22 In the good old times, there was the [Maven Hibernate3 Plugin](http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/), that does this for you. But unfortunatly, this plugin is not compatible with Hibernate 4.x. Since there does not seem to be any successor for the Maven Hibernate3 Plugin and [googeling](http://www.google.de/search?q=hibernate4+maven+plugin) does not help, I decided to write up this simple plugin (inspired by these two articles I found: [Schema Export with Hibernate 4 and Maven](http://www.tikalk.com/alm/blog/schema-export-hibernate-4-and-maven) and [Schema generation with Hibernate 4, JPA and Maven](http://doingenterprise.blogspot.de/2012/05/schema-generation-with-hibernate-4-jpa.html)).
23
24 I hope, the resulting simple to use buletproof [hibernate4-maven-plugin](/hibernate4-maven-plugin/) is usefull!
25
26 **[Try it out now!](/hibernate4-maven-plugin/)**