'Spring data specification with subquery and multiple in clause

I would like to create a specification with subquery and multiple in clause, how can I do it with JPA criteria?

basically, I want to convert below native SQL to spring data specification?

SELECT * FROM table
where (x_id, version) IN (select x_id , max(version) from table group by x_id)

thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source