My database has email as ID and another column zipCode as JSON type. Querying directly in MySQL like this is working:
SELECT * FROM Test WHERE
JSON_CONTAINS(testJson, '12345');
So testJson is the JSON type column with JSON arrays like:
[22079, 22310, 12345, 65412, 78954]
I'm trying to replicate the above in Hibernate:
session.createQuery( "from " + ZipCodes.class.getSimpleName() + " where JSON_CONTAINS(zipCodes, zipCodes=:zipCode )")
.setParameter("zipCode", zipCode)
.getResultList();
But I'm getting this exception:
unexpected AST node: ( near line 1, column 60 [ where JSON_CONTAINS(zipCodes, zipCodes=:zipCode )]
I don't know how to construct my JSON_CONTAINS clause.
JSON_CONTAINS(zipCodes, :zipCode ). I'm not sure it will work.