【无标题】

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

相关推荐
一拳一个娘娘腔12 小时前
【后渗透-Linux篇】Linux 提权与逃逸:从 www-data到 root的蜕变
linux·运维·服务器
郑州光合科技余经理12 小时前
海外外卖平台源码改造实战——多语言核心代码实现
java·开发语言·前端·后端·mysql·架构·php
耀耀_很无聊12 小时前
12_Redis Lua 脚本踩坑:为什么 tonumber(ARGV[x]) 会得到 nil?
java·redis·lua
shx_wei13 小时前
从函数调用到进程替换:使用 execl、CMake 与 PowerShell 构建一个多可执行程序
linux·c语言·windows·c
奶油话梅糖13 小时前
锐捷常用命令速查表
java·网络·windows
Dlrb121113 小时前
信息查询Web服务器-->电子商城信息查询项目
linux·服务器·数据库·html·嵌入式·epoll·数据查询
code_std13 小时前
java WebSocket 使用
java·开发语言·websocket
落叶-IT13 小时前
Java Scanner 类精讲:控制台交互
java·开发语言
love530love13 小时前
CodexPro + MCP + Cloudflare 配置详解:HTTP2、QUIC 与连接排障
ide·人工智能·windows·ai agent
chh56313 小时前
C++--string
java·开发语言·网络·c++·学习