Go Directly To
Oracle Technology Network Community
My Oracle Support Community
OPN Cloud Connection
Oracle Employee Community
Oracle User Group Community
OTN Speaker Bureau
Get Started Guide
Join the world’s largest interactive community dedicated to Oracle technologies.
Learn from thousands of community experts
Get answers to your technical questions
Share your knowledge with peers
Please enter a title.
You can not post a blank message. Please type your message and try again.
This discussion is archived
on Mar 27, 2012 12:49 PM by james_sutherland
Can anyexpert pls tell me eqivalent JPA2 Criteria query fo following
Mar 24, 2012 7:04 PM
select * FROM ( select * from customer_info where fname like '%sap%' ) XYZ where lname like '%ln%'
following sample query
but how do i add my subquery in criteriaQuery.from instead of customerinfo.class
thank you very much
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CustomerInfo> criteriaQuery = criteriaBuilder.createQuery(CustomerInfo.class);
Subquery<CustomerInfo> subquery = criteriaQuery.subquery(CustomerInfo.class);
Root fromSimpleBean = subquery.from(CustomerInfo.class);
Root<CustomerInfo> from = criteriaQuery.from(CustomerInfo.class);
CriteriaQuery<CustomerInfo> select = criteriaQuery.select(from);
TypedQuery<CustomerInfo> typedQuery = entityManager.createQuery(select);
List<CustomerInfo> resultList = typedQuery.getResultList();
I have the same question
Show 0 Likes
This content has been marked as final.
Show 1 reply
Re: Can anyexpert pls tell me eqivalent JPA2 Criteria query fo following
Mar 27, 2012 12:49 PM
in response to
Your query seems very odd, why not just do,
select c.* FROM customer_info c where c.fname like '%sap%' and c.lname like '%ln%'
In general sub-selects in the FROM clause are not supported in Criteria.
EclipseLink 2.4 will add support for sub-selects in the FROM clause in Expressions and hopefully JPQL, Criteria may be possible using Expressions with Criteria.