Exemple #1
0
 @Override
 public List<Question> findByTestId(Long testId) {
   return jdbcTemplate.query(
       FIND_ALL_SQL,
       new Object[] {testId},
       (rs, i) -> {
         Question question = new Question();
         question.setId(rs.getLong("id"));
         question.setQuestion(rs.getString("question"));
         question.setTestId(rs.getLong("test_id"));
         question.setSize(rs.getInt("size"));
         return question;
       });
 }
Exemple #2
0
 @Override
 public Question get(Long id) {
   return jdbcTemplate.query(
       "SELECT * FROM QUESTION WHERE ID = ?",
       new Object[] {id},
       rs -> {
         rs.next();
         Question question = new Question();
         question.setId(rs.getLong("id"));
         question.setQuestion(rs.getString("question"));
         question.setTestId(rs.getLong("test_id"));
         return question;
       });
 }
Exemple #3
0
 @Override
 public Question getQuestion(String str) {
   String sql = "SELECT * FROM question WHERE ID = ?";
   return jdbcTemplate.query(
       sql,
       resultSet -> {
         Question question = null;
         if (resultSet.next()) {
           question = new Question();
           question.setId(resultSet.getLong("id"));
           question.setQuestion(resultSet.getString("question"));
           question.setTestId(resultSet.getLong("test_id"));
         }
         return question;
       },
       str);
 }