Specification: Firebird 2.5, Hibernate 6.2 or 6.5 – yes I know this is odd composition since Firebird 2.5 is pretty outdated but for a while I have to live with it.
When I call custom method in CrudRepository or PagingAndSortingRepository with LIKE parameter the generated statement includes CONCAT function which is not supported by Firebird 2.5.
Example:
— Controller
Pageable paging = PageRequest.of(1, 10);
Page<MaterialBrand> items = repository.findByNormQuery(query, paging);
— Repository
@Query(
value = "select distinct t_m_gatunki.gatunek, .... where norm_symbol like %:norm%",
nativeQuery = true
)
Page<MaterialBrand> findByNormQuery(@Param("norm") String norm, Pageable pageable);
Generated statement looks like this:
select distinct t_m_gatunki.gatunek ... where norm_symbol like CONCAT('%',?,'%')
Which results in Error.
When I use Database Tool to test query it is OK when query looks like this:
select distinct t_m_gatunki.gatunek ... where norm_symbol like '%' || 'norm_symbol' || '%')
So the question is – how to make workaround of this issue?
I have been browsing through Hibernate source code – especially FirebirdDialect (in hope of some custom modifications), but I can not find where exactly CONCAT function is inserted.
Hope for any solution
Zadra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3