Query Criteria with JPA 1.0

Is it possible to use CriteriaQuery with JPA 1.0. I think JPA 2.0 is not available with Java Se (version is Java (TM) SE Runtime Environment (build 1.6.0_16-b01)). I got attached to using

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Test> cq = cb.createQuery(Test.class);
Root<Test> test= cq.from(Test.class);

....

But could not find the definition of CriteriaBuilder in javax.persistence. *; (tried to import javax.persistence.criteria.CriteriaBuilder; also)

If this is not possible, I have a better option. I use hibernation in the backend, but is there still an improper way to do this? if not how to do in sleep mode?

thank.

+3
source share
2 answers

Is it possible to use CriteriaQuery with JPA 1.0.

, JPA 1.0 API- Criteria, API- JPA 2.0.

, JPA 2.0 Java SE

JPA 1.0, JPA 2.0 Java SE ( ). JPA (1.0 2.0) Java SE.

(...) CriteriaBuilder javax.persistence. *

, API JPA 1.0, , JPA 2.0.

, . , ? , ?

Hibernate API Queries Queries. Session:

org.hibernate.Session session = (Session) em.getDelegate(); 
Criteria crit = session.createCriteria(Cat.class);
crit.setMaxResults(50);
List cats = crit.list();

+6

JPA2, , Java SE, JDK.

JPA1 , getCriteriaBuilder() EntityManager, JPA2.

hibernate-entitymanager.jar Hibernate 3.5+ JPA2 api Hibernate JPA Java SE.

Hibernate Core Hibernate Entity Manager, , EntityManager Java SE.

0

Source: https://habr.com/ru/post/1759540/


All Articles