Google

Sep 30, 2013

Hibernate dependencies jars and plugins

Here is a sample maven pom.xml snippets containing the dependency jars. 


....
<hibernate.version>4.1.3.Final</hibernate.version>
<hibernate-jpa-2.0-api.version>1.0.1.Final</hibernate-jpa-2.0-api.version>
<hibernate-validator-annotation-processor>4.2.0.Final</hibernate-validator-annotation-processor>
<hibernate-validator.version>4.3.0.Final</hibernate-validator.version>



The above snippet defines the version numbers.


The snippet below defines the dependencies.

...
<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
 <groupId>org.hibernate.javax.persistence</groupId>
 <artifactId>hibernate-jpa-2.0-api</artifactId>
</dependency>

<dependency>
 <groupId>javax.validation</groupId>
 <artifactId>validation-api</artifactId>
</dependency>

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator</artifactId>
</dependency>
   
<dependency>
 <groupId>org.hibernate.javax.persistence</groupId>
 <artifactId>hibernate-jpa-2.0-api</artifactId>
 <version>${hibernate-jpa-2.0-api.version}</version>
</dependency>

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator-annotation-processor</artifactId>
 <version>${hibernate-validator-annotation-processor}</version>
</dependency>


<!-- bean validation -->
<dependency>
 <groupId>javax.validation</groupId>
 <artifactId>validation-api</artifactId>
 <version>1.0.0.GA</version>
</dependency>

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator</artifactId>
 <version>${hibernate-validator.version}</version>
</dependency>




If you want to auto-generate your hibernate entities from DDL then.

   <build>
  <resources>
   <resource>
    <directory>${basedir}/src/main/resources</directory>
    <includes>
     <include>**/*</include>
    </includes>
   </resource>
  </resources>

  <plugins>
   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <configuration>
     <components>
      <component>
       <name>hbm2ddl</name>
       <implementation>jpaconfiguration</implementation>
      </component>
      <component>
       <name>hbmdoc</name>
      </component>
     </components>
     <componentProperties>
      <persistenceunit>my-data</persistenceunit>
      <outputfilename>schema.ddl</outputfilename>
      <drop>true</drop>
      <create>true</create>
      <export>false</export>
      <format>true</format>
     </componentProperties>
    </configuration>
   </plugin>
  </plugins>
 </build>


Finally, the plugin that is required for auto generation.

 <pluginManagement>
 <plugins>
  <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>hibernate3-maven-plugin</artifactId>
   <version>2.2</version>
  </plugin>
     </plugins>
  </pluginManagement> 

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home