use of org.springframework.jdbc.core.RowCallbackHandler in project dal by ctripcorp.
the class DaoByTableViewSp method updateAndGetAllTasks.
public List<GenTaskByTableViewSp> updateAndGetAllTasks(int projectId) {
final List<GenTaskByTableViewSp> tasks = new ArrayList<>();
this.jdbcTemplate.query("SELECT id, project_id,db_name,table_names,view_names,sp_names,prefix,suffix,cud_by_sp," + "pagination,`generated`,version,update_user_no,update_time,comment," + "sql_style,api_list,approved,approveMsg FROM task_table WHERE project_id=?", new Object[] { projectId }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
GenTaskByTableViewSp task = GenTaskByTableViewSp.visitRow(rs);
task.setGenerated(true);
if (updateTask(task) > 0) {
tasks.add(task);
}
}
});
return tasks;
}
use of org.springframework.jdbc.core.RowCallbackHandler in project dhis2-core by dhis2.
the class HibernateOrganisationUnitStore method getOrganisationUnitDataSetAssocationMap.
@Override
public Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap() {
final String sql = "select ds.uid as ds_uid, ou.uid as ou_uid from datasetsource d " + "left join organisationunit ou on ou.organisationunitid=d.sourceid " + "left join dataset ds on ds.datasetid=d.datasetid";
final SetMap<String, String> map = new SetMap<>();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
String dataSetId = rs.getString("ds_uid");
String organisationUnitId = rs.getString("ou_uid");
map.putValue(organisationUnitId, dataSetId);
}
});
return map;
}
use of org.springframework.jdbc.core.RowCallbackHandler in project musiccabinet by hakko.
the class JdbcLibraryPresenceDao method getFiles.
@Override
public Set<File> getFiles(String directory) {
String sql = "select d.path, f.filename, f.modified, f.size from library.file f" + " inner join library.directory d on f.directory_id = d.id" + " where d.path = ?";
final Set<File> files = new HashSet<>();
jdbcTemplate.query(sql, new Object[] { directory }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
String directory = rs.getString(1);
String filename = rs.getString(2);
DateTime modified = new DateTime(rs.getTimestamp(3).getTime());
int size = rs.getInt(4);
files.add(new File(directory, filename, modified, size));
}
});
return files;
}
use of org.springframework.jdbc.core.RowCallbackHandler in project musiccabinet by hakko.
the class JdbcTagDao method getCorrectedTags.
@Override
public Map<String, String> getCorrectedTags() {
String sql = "select t.tag_name, tc.tag_name from music.tag t" + " inner join music.tag tc on t.corrected_id = tc.id";
final Map<String, String> correctedTags = new HashMap<>();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
correctedTags.put(rs.getString(1), rs.getString(2));
}
});
return correctedTags;
}
use of org.springframework.jdbc.core.RowCallbackHandler in project spring-framework by spring-projects.
the class NamedParameterJdbcTemplateTests method testQueryWithRowCallbackHandler.
@Test
public void testQueryWithRowCallbackHandler() throws SQLException {
given(resultSet.next()).willReturn(true, false);
given(resultSet.getInt("id")).willReturn(1);
given(resultSet.getString("forename")).willReturn("rod");
params.put("id", new SqlParameterValue(Types.DECIMAL, 1));
params.put("country", "UK");
final List<Customer> customers = new LinkedList<>();
namedParameterTemplate.query(SELECT_NAMED_PARAMETERS, params, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
Customer cust = new Customer();
cust.setId(rs.getInt(COLUMN_NAMES[0]));
cust.setForename(rs.getString(COLUMN_NAMES[1]));
customers.add(cust);
}
});
assertEquals(1, customers.size());
assertTrue("Customer id was assigned correctly", customers.get(0).getId() == 1);
assertTrue("Customer forename was assigned correctly", customers.get(0).getForename().equals("rod"));
verify(connection).prepareStatement(SELECT_NAMED_PARAMETERS_PARSED);
verify(preparedStatement).setObject(1, 1, Types.DECIMAL);
verify(preparedStatement).setString(2, "UK");
verify(preparedStatement).close();
verify(connection).close();
}
Aggregations