Apache Maven 3 Cookbook
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 5<br />
Not surprisingly, we find Hibernate's stated goal being:<br />
"..to relieve the developer from 95 percent of common data persistence related<br />
programming tasks"<br />
Getting ready<br />
To use Hibernate in our <strong>Maven</strong> project, we will implement the <strong>Maven</strong> Hibernate3 plugin found<br />
at http://mojo.codehaus.org/maven-hibernate3.<br />
But first, we will create a simple <strong>Maven</strong> Java project and implement Hibernate-based<br />
persistence. Use the following command to create a <strong>Maven</strong> Java project based on<br />
maven-archetype-quickstart:<br />
$ mvn archetype:generate -DarchetypeArtifactId=maven-archetypequickstart<br />
-DgroupId=net.srirangan.packt.maven -DartifactId=TestAppCreate<br />
-Dversion=1.0.0<br />
This will create a simple <strong>Maven</strong> Java project with a valid POM file. If you have some basic<br />
knowledge of Hibernate 3, it will be helpful in going along. This recipe will help merge this<br />
knowhow of Hibernate 3 with your <strong>Maven</strong> project. Hibernate, in itself, is a vast topic and has<br />
entire books dedicated to it. However, we will take a quick look at implementing Hibernate in<br />
this project and complementing it with the use of the Hibernate <strong>Maven</strong> plugin.<br />
How to do it...<br />
The first step is to identify and include all of Hibernate's artifacts and its dependencies<br />
into your <strong>Maven</strong> project. Open the pom.xml file of your <strong>Maven</strong> project and include the<br />
following dependencies:<br />
<br />
org.hibernate<br />
hibernate-annotations<br />
3.4.0.GA<br />
jar<br />
compile<br />
<br />
<br />
org.hibernate<br />
hibernate-core<br />
3.3.2.GA<br />
jar<br />
compile<br />
<br />
<br />
113