【无标题】

java 复制代码
@RestResource(exported = false)
@Query("""
        SELECT DISTINCT fq FROM FilterQuery fq
        WHERE (
        ( :filterName is NULL OR fq.filterName LIKE CONCAT('%', :filterName, '%'))
        AND (:ownerId IS NULL OR fq.owner.id = :ownerId)
        """)
Page<FilterQueryListProjection> findAllWithViewPermission(@Param("userId") Long userId,
                                            @Param("groupIds") List<Long> groupIds,
                                            @Param("filterName") String filterName,
                                            @Param("ownerId") Long ownerId,
                                            Pageable pageable);

hql 会报错

java 复制代码
Caused by: org.hibernate.exception.SQLGrammarException: JDBC exception executing SQL [select distinct fq1_0.id,fq1_0.created_by,fq1_0.created_time,fq1_0.description,fq1_0.entity_name,fq1_0.filter,fq1_0.filter_name,fq1_0.hql_condition,fq1_0.is_default,fq1_0.owner_id,fq1_0.spel_condition,fq1_0.sql_condition,fq1_0.updated_by,fq1_0.updated_time from filter_query fq1_0 where (fq1_0.owner_id=? or not exists(select 1 from filter_query_permission_set fqps1_0 where fqps1_0.filter_query_id=fq1_0.id and fqps1_0.permission_type='VIEW') or exists(select 1 from filter_query_permission fqp1_0 join filter_query_permission_set ps1_0 on ps1_0.id=fqp1_0.permission_set_id where ps1_0.filter_query_id=fq1_0.id and ps1_0.permission_type='VIEW' and fqp1_0.user_id=?) or exists(select 1 from filter_query_permission fqp2_0 join filter_query_permission_set ps2_0 on ps2_0.id=fqp2_0.permission_set_id where ps2_0.filter_query_id=fq1_0.id and ps2_0.permission_type='VIEW' and fqp2_0.group_id in (?,?,?))) and (? is null or fq1_0.filter_name like ('%'||?||'%') escape '') and (? is null or fq1_0.owner_id=?) order by fq1_0.created_time desc fetch first ? rows only] [ERROR: operator does not exist: character varying ~~ bytea

关键: [ERROR: operator does not exist: character varying ~~ bytea

改成

复制代码
AND ( COALESCE(:filterName, '') = '' OR fq.filterName LIKE CONCAT('%', :filterName, '%')) 

就ok

相关推荐
唐青枫4 小时前
Java JDBC 实战指南:从 Connection 到事务和连接池
java
一个做软件开发的牛马5 小时前
MyBatis-Plus 从零实战:完整搭建可运行 Demo,BaseMapper 零 SQL、Wrapper 条件构造、分页插件与代码生成器详解
java·后端
用户3721574261355 小时前
Java 处理 PDF 图片:提取 PDF 中的图片,并压缩 PDF 图片体积
java
用户3721574261355 小时前
Java 打印 Word 文档:从基础打印到高级设置
java
用户35218024547521 小时前
当 Prompt 学会"热更新":Spring Boot × Nacos3 AI 实战
java·spring boot·ai编程
东坡白菜1 天前
破局全栈:一个前端开发的Java入门实战记录(1)
java·全栈
唐青枫1 天前
Java Tomcat 实战指南:从 Servlet 容器到 Spring Boot 部署
java
wsaaaqqq1 天前
roudan:自由选择实体、灵活操作数据、快速写入数据库的 Java 框架
java
plainGeekDev1 天前
null 判断 → Kotlin 可空类型
android·java·kotlin
糖拌西瓜皮1 天前
Java开发者视角:深入理解Node.js异步编程模型
java·后端·node.js