Created
October 23, 2019 03:07
-
-
Save tinmegali/d4e4d9abc516da7f5e1ed1e33438e5fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// reference: https://codingexplained.com/coding/java/spring-framework/return-boolean-value-from-spring-data-jpa-query | |
@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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment