Skip to content

Instantly share code, notes, and snippets.

@leewin12
Last active September 20, 2024 02:21
Show Gist options
  • Save leewin12/ff3c557e2b26ee403377a1c044812297 to your computer and use it in GitHub Desktop.
Save leewin12/ff3c557e2b26ee403377a1c044812297 to your computer and use it in GitHub Desktop.
Build JPA 2.0 CriteriaQuery with MySQL JSON column
CriteriaBuilder cb = new CriteriaBuilder();
// = SELECT * FROM entity WHERE JSON_EXTRACT("json_column", "$.path")
Root<entity> root;
cb.equal(
cb.function("JSON_EXTRACT", Integer.class, root.get("json_column"), "$.path"),
100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment