save single sql query result boolean spring boot

Solutions on MaxInterview for save single sql query result boolean spring boot by the best coders in the world

showing results for - "save single sql query result boolean spring boot"
Andrea
20 Jan 2017
1@Repository
2public interface CompanyRepository extends JpaRepository<Company, Integer> {
3    @Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM Company c WHERE c.name = :companyName")
4    boolean existsByName(@Param("companyName") String companyName);
5}