3

I’m using Maven 3, JPA 2.1, and Hibernate 4.3.5.Final. I want to use JPA 2.1 because it offers several features, most notably adding conditions to left outer join clauses. I have included the following dependencies in my Maven project …

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.0.Final</version>
    </dependency>   
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.3.2.Final</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.6.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>4.3.6.Final</version>
    </dependency>

However, when I try and compile the following, I get a compilation error (“cannot find symbol”) on the “.on(“ clause.

    final CriteriaBuilder cb = m_entityManager.getCriteriaBuilder();
    CriteriaQuery<Message> query = cb.createQuery(Message.class);
    Root<Message> messageRoot = query.from(Message.class);
    final Join<Message, Group> groupJoin = messageRoot.join(Message_.group);
    final Join<Message, MessageReadDate> msgReadDateJoin = messageRoot.join(Message_.messageReads, JoinType.LEFT);
    msgReadDateJoin.on(msgReadDateJoin.get(MessageReadDate_.recipient), recipient);

What libraries do I need to include in my Maven project to get JPA 2.1 and hence the “join.on” functionality?

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

1

It could be a maven issue. Usually happens if the jars that it downloaded are corrupted for some reason. Delete the .m2 folder repository and do mvn install again, it should bring all the enw jars and compilation should work.

m2 folder here

Community
  • 1
  • 1
Zeus
  • 6,386
  • 6
  • 54
  • 89
  • I deleted everything in my ~/.m2/org/hibernate folders, re-built, but still got the compilation error. – Dave Sep 24 '14 at 19:43
  • 1
    @Dave If using the eclipse, can you navigate the jar file and see what's in the Join.class file of the JPA jar file? Hint: Do F3 on Criteriabuilder class then Join class should be next to that if they are in the same package – Zeus Sep 24 '14 at 19:57