Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

save single sql query result boolean spring boot

@Repository
public interface CompanyRepository extends JpaRepository<Company, Integer> {
    @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);
}
Source by codingexplained.com #
 
PREVIOUS NEXT
Tagged: #save #single #sql #query #result #boolean #spring #boot
ADD COMMENT
Topic
Name
8+6 =