本文整理汇总了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);
}
}
}