I have a problem with Java Lambda Expressions. I am using Spring 4, JdbcTemplate, Java 8. Intellij IDEA shows "Loopback". What is it and how to fix it? Thank you for the attention.
@Override
public User getUser(long id) {
return jdbcTemplate.query("SELECT * FROM user WHERE id = ?",
ps -> {
ps.setLong(1, id);
},
(rs, rowNum) -> {
return new User(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getLong(4), rs.getBoolean(5));
});
}

solvable
This function returns a list, not a user. And the correct function is this:
@Override
public User getUser(long id) {
return jdbcTemplate.query("SELECT * FROM user WHERE id = ?",
ps -> {
ps.setLong(1, id);
},
(rs, rowNum) -> {
return new User(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getLong(4), rs.getBoolean(5));
}).get(0);
}
source
share