Francisco Spaeth
Francisco Spaeth

Reputation: 23913

JPA Select from (Select)

Is there some way to represent this kind of SQL with JPA or Hibernate Crtiteria API? Or shall I execute it as native?

SELECT A.X FROM (SELECT X, E.id FROM Employee E) as A WHERE A.id = 10

Upvotes: 1

Views: 498

Answers (1)

JB Nizet
JB Nizet

Reputation: 692121

From the documentation:

Note that HQL subqueries can occur only in the select or where clauses.

So yes, such a query can only be done using native SQL.

Upvotes: 1

Related Questions