📜  保存单个 sql 查询结果 boolean spring boot - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:36.483000             🧑  作者: Mango

代码示例1
@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);
}