【无标题】

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

相关推荐
萧瑟余晖20 分钟前
Java深入解析篇三十六之分布式系统详解
java·开发语言·分布式
KaKa_大王1 小时前
关于秒杀项目的一些理解
java·学习
tomla1 小时前
使用Java VisualVM观察过期对象引用现象
java
M1A11 小时前
Spring Boot YAML 配置读取完全指南:从基础到微服务
java
古法安卓1 小时前
Android-SELinux 策略调试实战:从 AVC 日志到策略修复
android·java·android studio
todoitbo1 小时前
飞算JavaAI的多租户权限隔离实测
java·springboot·ai编程·java开发·飞算javaai·java代码生成
星空1 小时前
Springboot复习
java·spring boot·spring
Dicky-_-zhang1 小时前
大模型部署架构:从推理引擎到弹性扩缩容的工程实践
java·jvm
vHelios2 小时前
【电商项目】商品搜索开发复盘(1):根据需求拆解搜索接口的设计逻辑
java·微服务·es
茶本无香2 小时前
@PostConstruct 注解完全指南
java·postconstruct