Home > Java > Generating sql database schema with maven2 for hibernate3

Generating sql database schema with maven2 for hibernate3

I’m using maven with hibernate3 plugin to generate the sql code for my database schema/tables. I do so with the following configuration.
Also make sure you declare your driver in the plugin dependencies to be sure the driver can be loaded in the plugin. Otherwise you might get some JDBC exceptions.

Command line example:
mvn clean compile hibernate3:hbm2ddl
			<!-- 
				Hibernate 3 Plugin, used for schema creation
				Usage example: mvn clean compile hibernate3:hbm2ddl
			 -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>hibernate3-maven-plugin</artifactId>
				<version>2.0-alpha-2</version>
				<configuration>
					<components>
						<component>
							<name>hbm2ddl</name>
							<implementation>annotationconfiguration</implementation>																									
						</component>							
					</components>
					<componentProperties>		
						<!-- Create Drop Statements -->					
						<drop>false</drop>
						<!-- Enable Annotations -->
						<jdk5>true</jdk5>
						<!-- Define Database Properties to Use -->
						<propertyfile>target/classes/database.properties</propertyfile>
						<!-- Pretty Format SQL Code -->
						<format>true</format>
						<!-- Create tables automatically? -->
						<export>false</export>
						<!-- Output filename -->
						<outputfilename>schema.sql</outputfilename>
					</componentProperties>
				</configuration>						
				<dependencies>
					<dependency>
						<groupId>com.oracle</groupId>
						<artifactId>ojdbc14</artifactId>
						<version>${oracle-driver.version}</version>
					</dependency>
				</dependencies>
  1. August 16th, 2008 at 01:29 | #1

    HSQL’s in-process mode might help you.

  2. Wytze
    August 16th, 2008 at 08:54 | #2

    I don’t see what HSQLDB has to do with generating the schema for an oracle database. Could you point it out to me?

  3. pawloch
    November 23rd, 2010 at 23:55 | #3

    thanks for that code! was very helpful!

  4. April 28th, 2012 at 16:12 | #4

    I drop a comment whenever I like a article on a website or if I have something to add to the conversation. Usually it’s caused by the fire communicated in the post I read. And after this article cat brain.stuff > wordpress » Generating sql database schema with maven2 for hibernate3. I was actually excited enough to drop a leave a responsea response :-P I do have a few questions for you if you don’t mind. Is it just me or do some of these remarks look like they are written by brain dead visitors? :-P And, if you are posting on other online social sites, I’d like to keep up with everything new you have to post. Would you list the complete urls of all your social sites like your twitter feed, Facebook page or linkedin profile?

  5. May 3rd, 2012 at 12:33 | #5

    I like what you guys are up also. Such clever work and reporting! Carry on the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my web site :) .

  1. No trackbacks yet.