tags:

views:

665

answers:

2

Hello,

I'm building application that uses JPA, and I want to use Criteria API as described http://openjpa.apache.org/builds/latest/docs/manual/jpa_overview_criteria.html. More precisely this part:

EntityManager em = ... ; 
CriteriaBuilder queryBuilder = em.getCriteriaBuilder();
CriteriaQuery qdef = queryBuilder.createCriteriaQuery();

The problem is that there is no getCriteriaBuilder() method in my EntityManager and also CriteriaBuilder and CriteriaQuery cannot be found in the persistance-api-1.0.jar

What am I missing? As I'm using a wrong jar? Mine is from http://repo2.maven.org/maven2/javax/persistence/persistence-api/1.0/

Regrads, Oleksandr

A: 

I'm using JBoss 4.2.3 GA and it is working fine:


import javax.persistence.criteria;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.EntityManager;

   CriteriaBuilder cb = em.getCriteriaBuilder();
   CriteriaQuery cq = cb.createQuery();

Hadi Eskandari
+1  A: 

Criteria is in JPA2, and you have a jar for JPA1. There is no "official" JPA2.jar yet, but there is an Apache2 licensed one from Apache http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-jpa_2.0_spec/1.0-PFD2/

DataNucleus