Last active
March 7, 2024 22:56
-
-
Save dotJoel/f7d8445b538bf1a2bec3556f3f4f8d97 to your computer and use it in GitHub Desktop.
Using JPA, here is how I created a predicate that searches a JSONB column for any of the provided keys.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
builder.equal( | |
builder.function( | |
"JSONB_EXISTS_ANY", | |
Boolean.class, | |
root.get("nameOfJsonbColumnToSearch"), | |
builder.function( | |
"string_to_array", | |
String.class, | |
builder.literal(String.join(",", setOfValuesToSearchFor)), | |
builder.literal(",") | |
) | |
), | |
true | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment