I have Column type Jsonb postgreSQL. I have stored a List of same objects keys are same values are different. how to filter data?
JSON Example:
[{"name": "contractTitle", "type": "string", "index": "1", "label": "Contract Title", "value": "test 1", "validations": {"hide": false, "unique": true, "message": "Contract Title is a Required Field. 1000 characters max", "required": true, "maxLength": "1000"}, "defaultValue": ""},{"name": "contractPurpose", "type": "text", "index": "12", "label": "Contract Purpose", "validations": {"hide": false, "message": "Contract Purpose is a Required Field. 1000 characters max", "required": true, "maxLength": "1000"}}]
this is one row in DB it has list of objects in it. i want verify contract title value either it is unique or not. Any Solution in SpringDataJPA or JPA specification or Native Query?
criteriaBuilder.equal(
criteriaBuilder.function("jsonb_extract_path_text", String.class, root.get("fieldsValue"), criteriaBuilder.literal(key1)),
value1
)
This function i guess works for single object in Jsonb but I have a List in it.