title: Using jdbcTemplate.query with parameters
body: <p>I have 3 tables in Database Lecture--&lt; LectureGroups &gt;-- Groups.
  And I want to get schedule for a certain group on a certain day. I try to do it in this way:</p>
  <pre><code>@Repository
  public class Schedule {
  
      private static final String GET_GROUP_DAY_SCHEDULE = &quot;SELECT * FROM LECTURES &quot; +
              &quot;INNER JOIN LECTUREGROUPS ON LECTURES.ID = LECTUREGROUPS.LECTUREID &quot; +
              &quot;INNER JOIN GROUPS ON GROUPS.ID = LECTUREGROUPS.GROUPID &quot; +
              &quot;WHERE GROUPID = :GROUPID AND DATE = :DATE&quot;;
  
      @Autowired
      private JdbcTemplate jdbcTemplate;
  
      public List&lt;Lecture&gt; getGroupDayLectures(int groupId, LocalDateTime dateTime) {
          MapSqlParameterSource parameters =  new MapSqlParameterSource()
                  .addValue(&quot;groupid&quot;, groupId)
                  .addValue(&quot;date&quot;, dateTime);
          return jdbcTemplate.query(GET_GROUP_DAY_SCHEDULE, new BeanPropertyRowMapper&lt;&gt;(Lecture.class), parameters);
      }
  }
  </code></pre>
  <p>But I get an exception in query raw</p>
  <pre><code>Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.springframework.jdbc.core.namedparam.MapSqlParameterSource. Use setObject() with an explicit Types value to specify the type to use.
  </code></pre>
  <p>How I can fix it?
  I also used variant with</p>
  <pre><code>private static final String GET_GROUP_DAY_SCHEDULE = &quot;SELECT * FROM LECTURES &quot; +
              &quot;INNER JOIN LECTUREGROUPS ON LECTURES.ID = LECTUREGROUPS.LECTUREID &quot; +
              &quot;INNER JOIN GROUPS ON GROUPS.ID = LECTUREGROUPS.GROUPID &quot; +
              &quot;WHERE GROUPID = ? AND DATE = ?&quot;;
  
      @Autowired
      private JdbcTemplate jdbcTemplate;
  
      public List&lt;Lecture&gt; getGroupDayLectures(int groupId, LocalDateTime dateTime) {
          return jdbcTemplate.query(GET_GROUP_DAY_SCHEDULE, new Object[]{groupId, dateTime}, new BeanPropertyRowMapper&lt;&gt;(Lecture.class));
      }
  </code></pre>
  <p>and it works but return only 1 Lecture in list (it must be 3)</p>