Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am learning Hibernate (OR Mapping). I am using Maven for project management. However, I am currently reading a Hibernate book by O'Reilly, and they use ANT for their example. So my question is are there any difference between setting up hibernate with ANT and Maven?

Thanks in advance!

share|improve this question
    
I think, this url will be very much useful to you.. java4s.com/hibernate/hibernate-framework-index –  user72381 Nov 12 '12 at 3:54
add comment

2 Answers

up vote 2 down vote accepted

No there is no difference when you setup Hibernate either way. Using maven or ant will only change the way you configure, build, deploy your project.

The way you write Hibernate code will not change in any way if you use Maven or Ant.

In maven pom.xml you will have to add the repository as documented below -

 <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>        
        <dependency>
            <groupId>org.hibernate.common</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>4.0.1.Final</version>
            <classifier>tests</classifier>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>      
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.0.1.Final</version>
        </dependency>       
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.1.0.CR2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.4</version>
        </dependency>

And the following repository will have to be added -

    <repository>
        <id>JBoss</id>
        <name>JBoss Repsitory</name>
        <layout>default</layout>
        <url>http://repository.jboss.org/maven2</url>
    </repository>
share|improve this answer
    
To reduce the size of your Maven pom.xml, just include entity-manager and validator, the rest are internal dependencies from there. –  Gary Rowe Nov 13 '12 at 9:12
add comment

If you want to see a complete web application that provides:

  • Hibernate configuration through Spring
  • DAOs with Spring's HibernateTemplate
  • DTOs with JPA annotations (@Column, @OneToOne, @OneToMany, @ManyToOne etc)
  • examples of Hibernate user types for persisting Joda Time and Joda Money

then you might want to refer to the MultiBit Merchant project on GitHub.

It also features examples of RESTful APIs with HAL and uses Dropwizard which may come in useful to you later on when you come to integrate your Hibernate work into a web application. All the code is MIT license so just take it and use it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.