The best way to write a Spring Data Exists Query

Introduction In this article, I’m going to show you the best way to write a Spring Data Exists Query that’s efficient from an SQL perspective. While doing consulting, I’ve encountered several options that are commonly used without developers knowing there are actually better alternatives.


Introduction In this article, we are going to see how the SQL EXISTS operator works and when you should use it. Although the EXISTS operator has been available since SQL:86, the very first edition of the SQL Standard, I found that there are still many application developers who don’t realize how powerful SQL subquery expressions really are when it comes to filtering a given table based on a condition evaluated on a different table.