【无标题】

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

相关推荐
魏 无羡2 小时前
webclient
java·webclient
神仙别闹3 小时前
基于 C++ 实现两个有序链表序列的交集
java·c++·链表
swordbob4 小时前
ReentrantLock 与 AQS 完整学习手册
java·开发语言
m0_587383005 小时前
全民健身解决方案软件开发实战:从架构设计到落地指南
java·spring boot·spring·架构·需求分析
白山编程大哥5 小时前
Java OutputStreamWriter 详解:从字符到字节的桥梁
java·开发语言·python
刚入门的大一新生5 小时前
Linux-进程控制
linux·运维·服务器·c++
上火的金鱼妹5 小时前
K8S基础组件作用和关系整理
linux·运维·服务器·kubernetes
一技安身6 小时前
【信创】Docker‑Compose V2 两种离线部署(独立模式、插件模式)简易教程
java·docker·eureka
七夜zippoe6 小时前
为什么 2026 年每个 Java 团队都该懂 AI Agent
java·开发语言·人工智能
编程的一拳超人6 小时前
DeepSeek Harness Linux/macOS/Windows 本地下载、启动与模型配置指南
linux·windows·macos·deepseek