save single sql query result boolean spring boot code example
Example: save single sql query result boolean spring boot
@Repository
public interface CompanyRepository extends JpaRepository {
@Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM Company c WHERE c.name = :companyName")
boolean existsByName(@Param("companyName") String companyName);
}