fix: avoid null bytea in audit search JPQL
Hibernate binds null String params as bytea, causing PostgreSQL lower(bytea) error. Convert null search to empty string in service layer, use empty-string check in JPQL instead of IS NULL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,9 +25,9 @@ public interface AuditRepository extends JpaRepository<AuditEntity, UUID> {
|
|||||||
AND (:result IS NULL OR a.result = :result)
|
AND (:result IS NULL OR a.result = :result)
|
||||||
AND (:from IS NULL OR a.createdAt >= :from)
|
AND (:from IS NULL OR a.createdAt >= :from)
|
||||||
AND (:to IS NULL OR a.createdAt <= :to)
|
AND (:to IS NULL OR a.createdAt <= :to)
|
||||||
AND (:search IS NULL
|
AND (:search = ''
|
||||||
OR LOWER(a.actorEmail) LIKE LOWER(CONCAT('%', COALESCE(:search, ''), '%'))
|
OR LOWER(a.actorEmail) LIKE LOWER(CONCAT('%', :search, '%'))
|
||||||
OR LOWER(a.resource) LIKE LOWER(CONCAT('%', COALESCE(:search, ''), '%')))
|
OR LOWER(a.resource) LIKE LOWER(CONCAT('%', :search, '%')))
|
||||||
ORDER BY a.createdAt DESC
|
ORDER BY a.createdAt DESC
|
||||||
""")
|
""")
|
||||||
Page<AuditEntity> findFiltered(
|
Page<AuditEntity> findFiltered(
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class AuditService {
|
|||||||
public Page<AuditEntity> search(UUID tenantId, String action, String result,
|
public Page<AuditEntity> search(UUID tenantId, String action, String result,
|
||||||
Instant from, Instant to, String search,
|
Instant from, Instant to, String search,
|
||||||
Pageable pageable) {
|
Pageable pageable) {
|
||||||
return auditRepository.findFiltered(tenantId, action, result, from, to, search, pageable);
|
String safeSearch = (search != null && !search.isBlank()) ? search.trim() : "";
|
||||||
|
return auditRepository.findFiltered(tenantId, action, result, from, to, safeSearch, pageable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user