DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Java
  4. Harder Than it Should be - Hibernate Maven POM Dependencies

Harder Than it Should be - Hibernate Maven POM Dependencies

Pratik Patel user avatar by
Pratik Patel
·
Aug. 11, 08 · Interview
Like (0)
Save
Tweet
Share
52.91K Views

Join the DZone community and get the full member experience.

Join For Free

In preparation for my upcoming No Fluff Just Stuff session in Cincinnati, I decided to finally rework the code example to use Hibernate as the JPA provider - rather than using OpenJPA. Don't get me wrong, OpenJPA is a great persistence framework. However it has fewer features and is less widely supported than Hibernate.

One of the things I wanted to add to the 'Enterprise JPA' session was to show some reuse of JPA persistent objects with other frameworks, specifically, Grails. Grails is my favorite web development platform now-a-days, and it is built on top of Hibernate and Spring. I already use Spring heavily in the JPA sessions' demo code, and being able to reuse the JPA PC's with Grails would make for an awesome demo, and also show a real-world value add in using JPA.

Grails doesn't support "generic" JPA yet, though it's on the roadmap. Frankly, I don't think Grails should attempt to support JPA until JPA 2.0 hits the streets - it would just be too much work to bridge JPA 1.0 to the dynamic queries that Grails supports now with Hibernate - for the sake of 6 months when JPA 2.0 will be out. Of course, in my sessions I remind attendees that to do real work, you have to use JPA implementation specific extensions anyways (just like Grails does to do many of the cool things GORM provides).

Using OpenJPA in a Maven 2 based project was so simple - just add the OpenJPA dependency in the pom.xml and that's basically it! It loads all the OpenJPA dependencies all by itself, and everything just worked. Initially, I thought that putting in Hibernate support would be just as easy. Unfortunately, it wasn't - I finally broke down and deciphered the Hibernate Compatibility Matrix and got it all put together. Even with the matrix handy, it still took some trial and error. In the hopes of saving somebody else some angst getting a pom.xml with Hibernate dependencies working, I've included the one that worked for me below.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>CallTracker</groupId>
    <artifactId>JPA</artifactId>
    <name>CallTracker</name>
    <version>1.0</version>
    <description>Tracks Conference Calls </description>
    <dependencies>
        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.8.0.7</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>2.5.5</version>
        </dependency>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>8.3-603.jdbc4</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.2.6.ga</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.transaction</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-tools</artifactId>
            <version>3.2.0.ga</version>
        </dependency>
        <dependency>
            <groupId>geronimo-spec</groupId>
            <artifactId>geronimo-spec-jta</artifactId>
            <version>1.0-M1</version>
            <scope>test</scope>
        </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>3.0.0.ga</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-commons-annotations</artifactId>
      <version>3.3.0.ga</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>3.3.2.GA</version>
    </dependency>
  </dependencies>
</project>

From http://www.jroller.com/prpatel/

Hibernate Dependency Grail (web browser) Apache Maven

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Real-Time Analytics for IoT
  • How We Solved an OOM Issue in TiDB with GOMEMLIMIT
  • How To Build a Spring Boot GraalVM Image
  • Master Spring Boot 3 With GraalVM Native Image

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: