Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring json字段中的条件生成器查询_Spring_Postgresql_Hibernate_Criteria Api - Fatal编程技术网

Spring json字段中的条件生成器查询

Spring json字段中的条件生成器查询,spring,postgresql,hibernate,criteria-api,Spring,Postgresql,Hibernate,Criteria Api,我正在尝试使用Criteria Builder(如)构建一个查询,以便在JSONARRAY字段中查找如下字符串: [ { "family_class": "Electric", "family_name": "lightBulb" }, { "family_class": "Others", "family_name": "Oil" } ] @For

我正在尝试使用Criteria Builder(如)构建一个查询,以便在JSONARRAY字段中查找如下字符串:

    [
      {
         "family_class": "Electric",
         "family_name": "lightBulb"
       },
      {
         "family_class": "Others",
         "family_name": "Oil"
       }  
     ]
@Formula(value = "lower(jsonColumn::text)")
private String residuesToSearch;
一个选项是查找family_name属性,或者检查其中是否包含字符串

    if (residues != null && residues.length > 0) {


            List<Predicate> predicates = new ArrayList<Predicate>();

            for (String residue : residues) {
                predicates.add(cb.like(root.get("jsonColumn"), residue.toLowerCase()));

            } 


            cr.select(root).where(predicates.toArray(new Predicate[] {}));

            Query<SyncCollectionPoints> q = sess.createQuery(cr);

            List<SyncCollectionPoints> result= q.getResultList();

我只想返回jsonColumn字段中包含该字符串的行。

我让它这样工作:

    [
      {
         "family_class": "Electric",
         "family_name": "lightBulb"
       },
      {
         "family_class": "Others",
         "family_name": "Oil"
       }  
     ]
@Formula(value = "lower(jsonColumn::text)")
private String residuesToSearch;

只需一个简单的演员表演就可以了

你的
实体是什么,你能展示它吗?Hello@code Tester你能帮我看一下我的案例吗: