简体   繁体   中英

JPA Criteria API for WITH clause and subquery in FROM clause

I`m new to JPA and I would like to implement a query that contains WITH clause, and also subquery in FROM clause by using JPA Criteria API, for example:

WITH A AS(...) SELECT a1,a2 FROM A

and also:

SELECT b1, b2 FROM (SELECT c1,c2 FROM ...)

How do I supposed to achieve this goal by using JPA Criteria? Or is there any alternative solution is fine.

thanks for helping

This is not possible with JPQL/HQL and the reason is simple, this is not an entity based approach. The core concept for ORM's are entities and they operate on that level.

There's nothing wrong with plain SQL if you want to have efficient queries, just make sure you understand the implications using it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM