views:

34

answers:

1

How to express the exists clause with JPA?

A: 

Exists is perfectly legal in JPQL, just use it. Perhaps I don't understand the question though? It's a bit terse :)

SELECT user 
FROM SOUsers user
WHERE EXISTS (SELECT user0 
              FROM SOUsers user0 
              WHERE user0 = user.bestFriendWhoAnswersTheirQuestions
                    and user0.name = 'Roman')
Affe