How to query JSON columns using JPQL with Hypersistence Utils

38 Views Asked by At

How can I query JSON type column in JPQL using Hypersistence Utils.

@vlad-mihalcea has posted many examples to query the entites which involve JSON type column but I am looking for querying JSON columns using JPQL.

For example : Consider the below entity Machine

@Entity(name = "Machine")
public class Machine {
    
    @Id
    private Long id;

    @Type(IntArrayType.class)
    @Column(
        name = "sensor_values",
        columnDefinition = "integer[]"
    )
    private int[] sensorValues;

}

Now, I want to query those machine whose sensorValues contains "40". How can I query something like this?

NOTE : I can't use native queries and using MySQL database.

0

There are 0 best solutions below