Skip to content

Using Specification CriteriaBuilder with non-standard operators like % from pg_trgm #575

Answered by beikov
MinnDevelopment asked this question in Q&A
Discussion options

You must be logged in to vote

You can define an immutable inline function in PostgreSQL for the operator and use that instead, which will make use of the index.

Alternatively, you can use the sql bultin function through CriteriaBuilder.function() which is supported by Hibernate ORM and EclipseLink. That allows you to specify a string representing a SQL template with placeholders as first argument followed by varargs that are filled into that template. Take a look into the Hibernate ORM or EclipseLink documentation for more details.

Lastly, you can also register custom functions in Hibernate ORM and EclipseLink that render whatever SQL that you want. You use them through CriteriaBuilder.function() as well.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@MinnDevelopment
Comment options

@Spliterash
Comment options

Answer selected by MinnDevelopment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants