title: Select a few columns using NamedParameterJDBCTemplate
body: <p>I'm using NamedParameterJDBCTemplate in Spring and trying to select only few columns instead of all columns. But I am facing an error - org.SpringFramework.BadSqlGrammarException. </p>
  
  <p>My DAO Class has the following code.</p>
  
  <pre><code>@Autowired
  private NamedParameterJdbcTemplate npjt;
  
  ... // Some other code
  
  String query = "SELECT t.name AS NAME, t.city AS CITY FROM t WHERE t.country = :countryName";
  MapSqlParameterSource param = new MapSqlParameterSource();
  param.addValue("countryName", "GERMANY");
  List&lt;Person&gt; pl = npjt.query(sql,param, new PersonMapper()); // Throws org.SpringFramework.BadSqlGrammarException 
  </code></pre>
  
  <p>The Person Model Class is as follows.</p>
  
  <pre><code>public class Person {
  String name;
  String city;
  String country;
  String address;
  
  // All getters &amp; setters
  }
  </code></pre>
  
  <p>The Mapper Class is as follows.</p>
  
  <pre><code>public class PersonMapper implements RowMapper {
  
  public Person mapRow(ResultSet rs, int rowNum) throws SQLException {
      Person p = new Person();
      p.setName(rs.getString("NAME"));
      p.setCity(rs.getString("CITY"));
      return p;
    }
  
  }
  </code></pre>
  
  <p>Facing the error only if select a few columns. When doing a select *, things are working fine.</p>