java.sql.SQLSyntaxErrorException: ORA-00932: 数据类型不一致: 应为 BINARY, 但却获得 CHAR

今天写代码遇到的,检查了一下发现实际上是把null值作为参数了

遇到此类问题,需要检查传入的参数中是否有空值(null).

查询代码如下:

@Repository
public interface OssDao extends JpaRepository<OssFileEntity, Long> {

    @Query(nativeQuery = true, value =
            " SELECT " +
                    " \"uri\" " +
                    " FROM " +
                    "         \"oss_file\" " +
                    " WHERE " +
                    " \"namespace\" = :namespace " +
                    " AND \"prefix\" LIKE COALESCE (:prefix, '%%') " +
                    " AND \"name\" LIKE COALESCE (:fileName, '%%') "
    )
    List<String> findUriByCondition(@Param("namespace") String namespace,
                                    @Param("prefix") String prefix,
                                    @Param("fileName") String fileName);
}

为了做Oracle和MySQL兼容, 也是绞尽乳汁了

posted @ 2020-07-16 12:11  习惯沉淀  阅读(1992)  评论(0编辑  收藏  举报