Skip to content

Instantly share code, notes, and snippets.

@leewin12
Last active September 7, 2022 14:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • 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