In my PostgreSQL table I have a parts
column of type json
. I want to check if the given argument is contained in my json column.
This query works in the database:
select * from elements we
where parts::text like '%"CHEST"%'
However, it doesn't work in my repository, I'm not sure but it's probably jpql:
@Override
public List<ElementView> test() {
return entityManager.createQuery(
"SELECT DISTINCT w FROM ElementView w " +
"WHERE we.parts::text like '%CHEST%'", ElementView.class)
.getResultList();
}
Is it possible to use this query (or another) to check the json array in the repository?