entity manager doesn't have method getCriteriaBuilder()

Use:

    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>

And not:

    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
    </dependency>

Search in all libraries that are included in your project, and remove the ones containing persistence.xml except the one you need. Then reinclude them again.


In eclipse:

  • Project -> Properties -> Java Build Path -> Configure Build Path -> Libraries
  • remove references to javax/persistente
  • insert a reference to hibernate-jpa-2.0-api-/version/.jar

how to verify:

in your sourceDAO.java press F3 in EntityManagerFactory and look what .jar eclipse open.