Query Criteria in EJB 3

Can I use Criteria queries with EJB3 objects? If so, how can I combine them with EntityManager?

+5
source share
3 answers

JPA does not provide a criteria API, for example in Hibernate. But you can use ejb3criteria , a library that provides an API based on the Hibernate Criteria API to save EJB3 state. ejb3criteria can be used with any implementation of EJB3 execution.

0
source

, JPA 2.0, API- Criteria. JPA2:

EntityManager.getCriteriaBuilder() API .

EntityManager em = ...;
CriteriaBuilder qb = em.getCriteriaBuilder();
CriteriaQuery<Employee> query = qb.createQuery(Employee.class);
Root<Employee> employee = query.from(Employee.class);
query.where(qb.equal(employee.get("firstName"), "Bob"));
List<Employee> result = em.createQuery(query).getResultList();
+7

JPA 2 ( API) JSR 317, JSR 220 ( EJB/JPA). , ". JPA 1.0/EJB 3.0, ". , JPA 2 (WebLogic, JBOSS, Glassfish ..). JPA 2.0 . , JPA 1, JPA 1.

+1
source

All Articles