@Test public void testQuery() throws Exception { serviceInstanceDao.insertOrUpdate(newServiceInstance()); serviceInstanceDao.insertOrUpdate(newServiceInstance()); Assert.assertTrue(serviceInstanceDao.query().size() >= 2); }
public List<ServiceInstanceModel> query() { final String sql = "SELECT service_id, instance_id, ip, machine_name, metadata, port, protocol, region_id, zone_id, healthy_check_url, url, group_id from service_instance"; return DataConfig.jdbcTemplate().query(sql, new RowMapper<ServiceInstanceModel>() { @Override public ServiceInstanceModel mapRow(final ResultSet rs, final int rowNum) throws SQLException { ServiceInstanceModel serviceInstance = new ServiceInstanceModel(); serviceInstance.setServiceId(rs.getString(1)); serviceInstance.setInstanceId(rs.getString(2)); serviceInstance.setIp(rs.getString(3)); serviceInstance.setMachineName(rs.getString(4)); serviceInstance.setMetadata(rs.getString(5)); serviceInstance.setPort(rs.getInt(6)); serviceInstance.setProtocol(rs.getString(7)); serviceInstance.setRegionId(rs.getString(8)); serviceInstance.setZoneId(rs.getString(9)); serviceInstance.setHealthCheckUrl(rs.getString(10)); serviceInstance.setUrl(rs.getString(11)); serviceInstance.setGroupId(rs.getString(12)); return serviceInstance; } }); }
ServiceInstanceDao { public List<ServiceInstanceModel> query() { final String sql = "SELECT service_id, instance_id, ip, machine_name, metadata, port, protocol, region_id, zone_id, healthy_check_url, url, group_id from service_instance"; return DataConfig.jdbcTemplate().query(sql, new RowMapper<ServiceInstanceModel>() { @Override public ServiceInstanceModel mapRow(final ResultSet rs, final int rowNum) throws SQLException { ServiceInstanceModel serviceInstance = new ServiceInstanceModel(); serviceInstance.setServiceId(rs.getString(1)); serviceInstance.setInstanceId(rs.getString(2)); serviceInstance.setIp(rs.getString(3)); serviceInstance.setMachineName(rs.getString(4)); serviceInstance.setMetadata(rs.getString(5)); serviceInstance.setPort(rs.getInt(6)); serviceInstance.setProtocol(rs.getString(7)); serviceInstance.setRegionId(rs.getString(8)); serviceInstance.setZoneId(rs.getString(9)); serviceInstance.setHealthCheckUrl(rs.getString(10)); serviceInstance.setUrl(rs.getString(11)); serviceInstance.setGroupId(rs.getString(12)); return serviceInstance; } }); } }
ServiceInstanceDao { public List<ServiceInstanceModel> query() { final String sql = "SELECT service_id, instance_id, ip, machine_name, metadata, port, protocol, region_id, zone_id, healthy_check_url, url, group_id from service_instance"; return DataConfig.jdbcTemplate().query(sql, new RowMapper<ServiceInstanceModel>() { @Override public ServiceInstanceModel mapRow(final ResultSet rs, final int rowNum) throws SQLException { ServiceInstanceModel serviceInstance = new ServiceInstanceModel(); serviceInstance.setServiceId(rs.getString(1)); serviceInstance.setInstanceId(rs.getString(2)); serviceInstance.setIp(rs.getString(3)); serviceInstance.setMachineName(rs.getString(4)); serviceInstance.setMetadata(rs.getString(5)); serviceInstance.setPort(rs.getInt(6)); serviceInstance.setProtocol(rs.getString(7)); serviceInstance.setRegionId(rs.getString(8)); serviceInstance.setZoneId(rs.getString(9)); serviceInstance.setHealthCheckUrl(rs.getString(10)); serviceInstance.setUrl(rs.getString(11)); serviceInstance.setGroupId(rs.getString(12)); return serviceInstance; } }); } private  ServiceInstanceDao(); }
ServiceInstanceDao { public List<ServiceInstanceModel> query() { final String sql = "SELECT service_id, instance_id, ip, machine_name, metadata, port, protocol, region_id, zone_id, healthy_check_url, url, group_id from service_instance"; return DataConfig.jdbcTemplate().query(sql, new RowMapper<ServiceInstanceModel>() { @Override public ServiceInstanceModel mapRow(final ResultSet rs, final int rowNum) throws SQLException { ServiceInstanceModel serviceInstance = new ServiceInstanceModel(); serviceInstance.setServiceId(rs.getString(1)); serviceInstance.setInstanceId(rs.getString(2)); serviceInstance.setIp(rs.getString(3)); serviceInstance.setMachineName(rs.getString(4)); serviceInstance.setMetadata(rs.getString(5)); serviceInstance.setPort(rs.getInt(6)); serviceInstance.setProtocol(rs.getString(7)); serviceInstance.setRegionId(rs.getString(8)); serviceInstance.setZoneId(rs.getString(9)); serviceInstance.setHealthCheckUrl(rs.getString(10)); serviceInstance.setUrl(rs.getString(11)); serviceInstance.setGroupId(rs.getString(12)); return serviceInstance; } }); } private  ServiceInstanceDao(); List<ServiceInstanceModel> query(); List<ServiceInstanceModel> select(ServiceInstanceModel filter); List<ServiceInstanceModel> select(List<Long> groupIds); }
ServiceInstanceDao { public List<ServiceInstanceModel> query() { final String sql = "SELECT service_id, instance_id, ip, machine_name, metadata, port, protocol, region_id, zone_id, healthy_check_url, url, group_id from service_instance"; return DataConfig.jdbcTemplate().query(sql, new RowMapper<ServiceInstanceModel>() { @Override public ServiceInstanceModel mapRow(final ResultSet rs, final int rowNum) throws SQLException { ServiceInstanceModel serviceInstance = new ServiceInstanceModel(); serviceInstance.setServiceId(rs.getString(1)); serviceInstance.setInstanceId(rs.getString(2)); serviceInstance.setIp(rs.getString(3)); serviceInstance.setMachineName(rs.getString(4)); serviceInstance.setMetadata(rs.getString(5)); serviceInstance.setPort(rs.getInt(6)); serviceInstance.setProtocol(rs.getString(7)); serviceInstance.setRegionId(rs.getString(8)); serviceInstance.setZoneId(rs.getString(9)); serviceInstance.setHealthCheckUrl(rs.getString(10)); serviceInstance.setUrl(rs.getString(11)); serviceInstance.setGroupId(rs.getString(12)); return serviceInstance; } }); } private  ServiceInstanceDao(); List<ServiceInstanceModel> query(); List<ServiceInstanceModel> select(ServiceInstanceModel filter); List<ServiceInstanceModel> select(List<Long> groupIds); static final ServiceInstanceDao INSTANCE; }