@Test public void testSelect() { GroupInstanceModel groupInstance = newGroupInstance(); groupInstanceDao.insert(groupInstance); GroupInstanceModel filter = new GroupInstanceModel(); filter.setGroupId(groupInstance.getGroupId()); filter.setInstanceId(groupInstance.getInstanceId()); assertGroupInstance(groupInstance, groupInstanceDao.select(filter).get(0)); }
public List<GroupInstanceModel> select(GroupInstanceModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("group_id=?", filter.getGroupId() == null ? null : Long.toString(filter.getGroupId())); conditions.put("instance_id=?", filter.getInstanceId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (StringValues.isNullOrWhitespace(conditions.get(key))) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); }
GroupInstanceDao { public List<GroupInstanceModel> select(GroupInstanceModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("group_id=?", filter.getGroupId() == null ? null : Long.toString(filter.getGroupId())); conditions.put("instance_id=?", filter.getInstanceId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (StringValues.isNullOrWhitespace(conditions.get(key))) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); } }
GroupInstanceDao { public List<GroupInstanceModel> select(GroupInstanceModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("group_id=?", filter.getGroupId() == null ? null : Long.toString(filter.getGroupId())); conditions.put("instance_id=?", filter.getInstanceId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (StringValues.isNullOrWhitespace(conditions.get(key))) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); } private  GroupInstanceDao(); }
GroupInstanceDao { public List<GroupInstanceModel> select(GroupInstanceModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("group_id=?", filter.getGroupId() == null ? null : Long.toString(filter.getGroupId())); conditions.put("instance_id=?", filter.getInstanceId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (StringValues.isNullOrWhitespace(conditions.get(key))) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); } private  GroupInstanceDao(); List<GroupInstanceModel> query(); List<GroupInstanceModel> select(GroupInstanceModel filter); List<GroupInstanceModel> select(List<Long> groupIds); }
GroupInstanceDao { public List<GroupInstanceModel> select(GroupInstanceModel filter) { ValueCheckers.notNull(filter, "filter"); Map<String, String> conditions = Maps.newHashMap(); conditions.put("id=?", filter.getId() == null ? null : Long.toString(filter.getId())); conditions.put("group_id=?", filter.getGroupId() == null ? null : Long.toString(filter.getGroupId())); conditions.put("instance_id=?", filter.getInstanceId()); Set<String> removed = Sets.newHashSet(); for (String key : conditions.keySet()) { if (StringValues.isNullOrWhitespace(conditions.get(key))) { removed.add(key); } } conditions.keySet().removeAll(removed); return query(Joiner.on(" and ").join(conditions.keySet()), Lists.newArrayList(conditions.values())); } private  GroupInstanceDao(); List<GroupInstanceModel> query(); List<GroupInstanceModel> select(GroupInstanceModel filter); List<GroupInstanceModel> select(List<Long> groupIds); static final GroupInstanceDao INSTANCE; }