Archive for the ‘Java’ Category

Generating sql database schema with maven2 for hibernate3

July 31st, 2008 3 comments

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
						<!-- Create Drop Statements -->					
						<!-- Enable Annotations -->
						<!-- Define Database Properties to Use -->
						<!-- Pretty Format SQL Code -->
						<!-- Create tables automatically? -->
						<!-- Output filename -->

Using the maven exec plugin to launch hsqldb

July 31st, 2008 No comments

Below is a short snippet I use to launch hsqldb automatically for unit testing in my java projects.
Biggest limitation to the exec-maven-plugin is that it can’t run processes asynchronous. This way a running application is blocking the maven process flow. A big limitation. I think they should add an option to be able to run the process in a separate process without blocking the flow if needed.

Below is the snippet, I tried to use the windows start command. But it didn’t really work.

					<!-- Execute plugin to launch hsqldb -->
								start java 
									-cp "c:/Documents and Settings/%USERNAME%/.m2/repository/hsqldb/hsqldb/" 
									-database.0 mydb 
									-dbname.0 xdb							-->
							<!-- use start to execute in separate thread -->
							<!-- optional -->
								<argument>"C:/Documents and Settings/%USERNAME%/.m2/repository/hsqldb/hsqldb/"</argument>

Maven and Java dependencies

March 6th, 2008 No comments

When building some Java projects with maven you might run into some missing Sun jars/artifacts.

[INFO] Failed to resolve artifact.
1) javax.transaction:jta:jar:1.0.1B

Luckily you can fix this. 🙂

Go to the Java site and grab the file.
Then manually import the file into your local maven repository by running the following command:

mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B  -Dpackaging=jar

Now you have it. If you wish you can add this dependency to your pom.xml manually now also.


For more information look at maven’s mini-howto.

Categories: Java Tags: