qbc关联查询出对象集合,对集合中的对象进行条件过滤
2017-11-20 11:37
211 查看
项目中所有的数据都是逻辑删除,在查询方案下的食谱时,可以在查询食谱时加qbc条件进行过滤,对于食谱下的食谱详情需要将未删除的食谱查出后,对食谱的集合进行迭代,然后将不符合的食谱详情移除。代码如下:
//根据系统方案id查询方案的食谱 import java.util.Iterator; @Override public List<SystemSchemeRecipes> findBySystemSchemeIdAndStatus(Integer systemSchemeId) { try { Criteria criteria = dao.createCriteria(); criteria.add((Restrictions.eq("scheme.sysSchemeId", systemSchemeId))); criteria.add((Restrictions.eq("recipesStatus", 0))); //查询出的所有的未删除的食谱集合 List<SystemSchemeRecipes> recippesList1 =criteria.list(); if (recippesList1.size() > 0) { for (int i = 0; i < recippesList1.size(); i++) { //将查出的食谱详情集合放入迭代器中,进行遍历,判断如果状态为删除,则将其从返回集合中移除 Iterator<SystemSchemeRecipesInfo> iter = recippesList1.get(i).getSystemschemeRecipesInfos().iterator(); while (iter.hasNext()) { if (iter.next().getRecipesStatus() != 0) { iter.remove(); } } } } return recippesList1; } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage()); throw new BasicRuntimeException(this, "根据系统方案id查询方案的食谱异常" + e.getMessage()); } }
相关文章推荐
- 用于过滤集合的条件对象NSPredicate
- 将不确定变为确定~表达式树是否可以有个集合,条件过滤有了新方向续(新增了OR和AND查询)
- 如何对List集合中的对象进行按某个属性排序
- java中对List对象集合进行排序
- EF-Linq 将实体对象转换为搜索条件以进行通用动态查询
- 使用Comparable和Comparator对Java集合对象进行排序
- Java:对集合中的对象进行排序需要实现Interface Comparable接口并实现int compareTo(T o)方法
- 根据共享参数来过滤满足条件的对象(代码)
- 【转】C# ArcgisEngine开发中,对一个图层进行过滤,只显示符合条件的要素
- 字符串查询条件预处理 就是查询时某变量进行过滤处理
- html_angular 增删改查+批量发货 删除 范围查找(条件)+米/*过滤(使用功能大集合)
- 使用ActiveReport for .net 进行报表开发--显示对象集合中的数据
- 对List集合中的对象进行自定义排序
- 将不确定变为确定~表达式树是否可以有个集合,条件过滤有了新方向
- 对集合中的对象进行排序,用collections.sort 到方法
- 无合适where条件过滤时尽量选择order by后的字段以驱动表进行查询 推荐
- .NET/C#中对自定义对象集合进行自定义排序的方法
- java中Comparator的用法(用于集合对象或数组对象进行排序)
- Java:List集合内的对象进行排序
- 对于集合内装载的对象数据进行自定义排序 !