本文整理匯總了Java中org.springframework.jdbc.core.JdbcTemplate.queryForRowSet方法的典型用法代碼示例。如果您正苦於以下問題:Java JdbcTemplate.queryForRowSet方法的具體用法?Java JdbcTemplate.queryForRowSet怎麽用?Java JdbcTemplate.queryForRowSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.jdbc.core.JdbcTemplate
的用法示例。
在下文中一共展示了JdbcTemplate.queryForRowSet方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeDuplicateRows
import org.springframework.jdbc.core.JdbcTemplate; //導入方法依賴的package包/類
private void removeDuplicateRows(final JdbcTemplate jdbcTemplate, final Long zone) {
final List<SubjectEntity> subjects = jdbcTemplate
.query("SELECT DISTINCT subject_identifier, attributes FROM subject", new SubjectRowMapper());
jdbcTemplate.update("DELETE FROM subject *");
for (SubjectEntity s : subjects) {
jdbcTemplate.update("INSERT INTO subject (subject_identifier, attributes, "
+ " authorization_zone_id) VALUES (?,?,?)", s.getSubjectIdentifier(), s
.getAttributesAsJson(),
zone);
}
final List<ResourceEntity> resources = jdbcTemplate
.query("SELECT DISTINCT resource_identifier, attributes FROM resource", new ResourceRowMapper());
jdbcTemplate.update("DELETE FROM resource *");
for (ResourceEntity r : resources) {
jdbcTemplate.update("INSERT INTO resource (resource_identifier, attributes, "
+ " authorization_zone_id) VALUES (?,?,?)", r.getResourceIdentifier(), r
.getAttributesAsJson(),
zone);
}
final List<PolicySetEntity> policysets = jdbcTemplate
.query("SELECT DISTINCT policy_set_id, policy_set_json FROM policy_set", new PolicySetRowMapper());
jdbcTemplate.update("DELETE FROM policy_set *");
for (PolicySetEntity ps : policysets) {
SqlRowSet row = jdbcTemplate
.queryForRowSet("SELECT * FROM policy_set WHERE policy_set_id =?", ps.getPolicySetID());
if (row.next()) {
jdbcTemplate.update("UPDATE policy_set SET policy_set_json = ? WHERE policy_set_id = ?",
ps.getPolicySetJson(), ps.getPolicySetID());
} else {
jdbcTemplate.update("INSERT INTO policy_set (policy_set_id, policy_set_json, "
+ " authorization_zone_id) VALUES (?,?,?)", ps.getPolicySetID(), ps.getPolicySetJson(), zone);
}
}
}