Movie Repository


Java Spring Database abstraction Public New

Easy 

5min


Consider the following Spring bean:

public class MovieRepository {

    @Autowired
    private DataSource dataSource;

    public List<Movie> findMoviesByName(String name) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        return jdbcTemplate.query("select name, year, rating from movies where name like ?",
                new Object[]{name},
                new RowMapper<Movie>() {
                    @Override
                    public Movie mapRow(ResultSet resultSet, int i) throws SQLException {
                        return new Movie(resultSet.getString("name"),
                                resultSet.getInt("year"), resultSet.getInt("rating"));
                    }
                });
    }

}

Select the statements that are correct.

(multiple correct answers possible)