【无标题】

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

相关推荐
泡海椒7 分钟前
金融报表开发:jquick-pdf K 线图 PDF 可视化解决方案
java·开发语言·金融·pdf
华允物联-HUAIOT7 分钟前
带隔离的串口服务器有必要买吗?隔离作用对比
服务器·物联网
余槐i17 分钟前
rollbackFor 不设置,Checked 异常不回滚:Spring 默认规则与两行修复的取舍
java·spring boot·后端·spring·事务管理
嵌入式小能手22 分钟前
飞凌嵌入式ElfBoard-Shell编程应用实例-使用WiFi拨号上网
linux·服务器·网络
..Dauntless..23 分钟前
【Linux】环境变量
linux·运维·服务器
❀͜͡傀儡师24 分钟前
Spring AI 集成 TypeSafe:用判断模型处理工单分流与链路决策
java·人工智能·spring
硫酸锌0125 分钟前
在手机上运行Python增量备份手机数据到PC电脑
android·windows·python
bro_Java66627 分钟前
《栈与队列:数据结构的“双生花”》
java·数据结构·编辑器
花开路口29 分钟前
线程安全完全指南:从 Java 到 Kotlin,一文吃透并发编程
java·kotlin
她说..35 分钟前
IntelliJ IDEA 快捷键速查表(Mac 版)
java·macos·intellij-idea