Update Deprecated Spring Jdbc Usage
This commit is contained in:
+6
-7
@@ -226,10 +226,10 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
||||
* @return a list of GrantedAuthority objects for the user
|
||||
*/
|
||||
protected List<GrantedAuthority> loadUserAuthorities(String username) {
|
||||
return getJdbcTemplate().query(this.authoritiesByUsernameQuery, new String[] { username }, (rs, rowNum) -> {
|
||||
return getJdbcTemplate().query(this.authoritiesByUsernameQuery, (rs, rowNum) -> {
|
||||
String roleName = JdbcDaoImpl.this.rolePrefix + rs.getString(2);
|
||||
return new SimpleGrantedAuthority(roleName);
|
||||
});
|
||||
}, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,11 +238,10 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService, M
|
||||
* @return a list of GrantedAuthority objects for the user
|
||||
*/
|
||||
protected List<GrantedAuthority> loadGroupAuthorities(String username) {
|
||||
return getJdbcTemplate().query(this.groupAuthoritiesByUsernameQuery, new String[] { username },
|
||||
(rs, rowNum) -> {
|
||||
String roleName = getRolePrefix() + rs.getString(3);
|
||||
return new SimpleGrantedAuthority(roleName);
|
||||
});
|
||||
return getJdbcTemplate().query(this.groupAuthoritiesByUsernameQuery, (rs, rowNum) -> {
|
||||
String roleName = getRolePrefix() + rs.getString(3);
|
||||
return new SimpleGrantedAuthority(roleName);
|
||||
}, username);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-5
@@ -336,8 +336,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
|
||||
@Override
|
||||
public boolean userExists(String username) {
|
||||
List<String> users = getJdbcTemplate().queryForList(this.userExistsSql, new String[] { username },
|
||||
String.class);
|
||||
List<String> users = getJdbcTemplate().queryForList(this.userExistsSql, String.class, username);
|
||||
if (users.size() > 1) {
|
||||
throw new IncorrectResultSizeDataAccessException("More than one user found with name '" + username + "'",
|
||||
1);
|
||||
@@ -353,7 +352,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
@Override
|
||||
public List<String> findUsersInGroup(String groupName) {
|
||||
Assert.hasText(groupName, "groupName should have text");
|
||||
return getJdbcTemplate().queryForList(this.findUsersInGroupSql, new String[] { groupName }, String.class);
|
||||
return getJdbcTemplate().queryForList(this.findUsersInGroupSql, String.class, groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -422,8 +421,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
public List<GrantedAuthority> findGroupAuthorities(String groupName) {
|
||||
this.logger.debug("Loading authorities for group '" + groupName + "'");
|
||||
Assert.hasText(groupName, "groupName should have text");
|
||||
return getJdbcTemplate().query(this.groupAuthoritiesSql, new String[] { groupName },
|
||||
this.grantedAuthorityMapper);
|
||||
return getJdbcTemplate().query(this.groupAuthoritiesSql, this.grantedAuthorityMapper, groupName);
|
||||
}
|
||||
|
||||
private GrantedAuthority mapToGrantedAuthority(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
||||
Reference in New Issue
Block a user