首页 > 解决方案 > 需要为Query编写Spring Data JPA接口方法

问题描述

如何将以下本机转换为 Spring Data JPA 接口方法:

    @Query(nativeQuery = true,
            value = " select count(*) from TABLE "
                    + "where ( ColumOne =:xyz  or ColumnTwo =:xyz ) "
                    + "and STATUS_TX in ('On Hold')")
    int countAllByStatusAndName(@Param("xyz") String xyx);

我写成

Long countByStatusTXAndColumnOnOrColumnTwo (String status, String xyz). 但它不工作

我特别需要 ColumnOne 和 ColumnTwo 之间的那个或条件。

标签: javaspring-data-jpa

解决方案


方法名称似乎有错字。ColumnOn而不是ColumnOne. 尝试Long countByStatusTXAndColumnOneOrColumnTwo (String status, String xyz)


推荐阅读