Search code examples
jpa-2.0entitymanager

entity manager doesn't have method getCriteriaBuilder()


I am introducing JPA2.0 in my application working on Oracle9i database and I added the libraries EclipseLink(JPA2.0) and created the entity classes but when I use

javax.persistence.criteria.CriteriaQuery cq = em.getCriteriaBuilder().createQuery();

I get the following error

cannot find symbol symbol : method getCriteriaBuilder() location: interface javax.persistence.EntityManager

my web.xml is version 2.4 and here's my persistence.xml

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
   <persistence-unit name="MiraclinPU" transaction-type="JTA">
    <jta-data-source>jdbc/Miraclin</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties/>
   </persistence-unit>
</persistence>

It looks like the app is using JPA1.0 as I read on the forums...Can anyone help?


Solution

  • 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.