We are using Micronaut Data which appears to use Hibernate 6.4.4. I came across an issue where escape ''
is appended to a LIKE query that is generated from a repository method. I cannot seem to find how to set that value so our manually-escaped strings pass to postgres as expected. How can I set what value should be in the escape clause without manually writing the query?
Sorry, but this is not a Micronaut Data forum. You will have to ask that question elsewhere. When you write the query yourself, you can specify the escape character explicitly.
Ah, you are saying the escape ''
clause is being added by Micronaut, not Hibernate? Thanks!
Hibernate ORM by default has no escape character defined for the like
pattern, which is according to the SQL specification. To ensure this, when rendering SQL, Hibernate ORM has to emit escape ''
in the generated SQL on some databases that have a default escape character to implement the specified behavior. So if you want a specific escape character, you have to add that to your HQL like
predicate.
I don’t know what Micronaut is doing, I can only tell you how you can use HQL or the JPA Criteria API.