|
304 | 304 | <para>Here is a simple query for getting the number of rows in a |
305 | 305 | relation:</para> |
306 | 306 |
|
307 | | - <programlisting language="java">int rowCount = this.jdbcTemplate.queryForObject("select count(*) from t_actor", int.class);</programlisting> |
| 307 | + <programlisting language="java">int rowCount = this.jdbcTemplate.queryForObject("select count(*) from t_actor", Integer.class);</programlisting> |
308 | 308 |
|
309 | 309 | <para>A simple query using a bind variable:</para> |
310 | 310 |
|
311 | 311 | <programlisting language="java">int countOfActorsNamedJoe = this.jdbcTemplate.queryForObject( |
312 | | - "select count(*) from t_actor where first_name = ?", int.class, "Joe");</programlisting> |
| 312 | + "select count(*) from t_actor where first_name = ?", Integer.class, "Joe");</programlisting> |
313 | 313 |
|
314 | 314 | <para>Querying for a <classname>String</classname>:</para> |
315 | 315 |
|
@@ -567,7 +567,7 @@ public int countOfActorsByFirstName(String firstName) { |
567 | 567 |
|
568 | 568 | SqlParameterSource namedParameters = new MapSqlParameterSource("first_name", firstName); |
569 | 569 |
|
570 | | - return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters); |
| 570 | + return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters); |
571 | 571 | }</programlisting> |
572 | 572 |
|
573 | 573 | <para>Notice the use of the named parameter notation in the value |
@@ -600,7 +600,7 @@ public int countOfActorsByFirstName(String firstName) { |
600 | 600 |
|
601 | 601 | Map<String, String> namedParameters = Collections.singletonMap("first_name", firstName); |
602 | 602 |
|
603 | | - return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters); |
| 603 | + return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters); |
604 | 604 | }</programlisting> |
605 | 605 |
|
606 | 606 | <para>One nice feature related to the |
@@ -664,7 +664,7 @@ public int countOfActors(Actor exampleActor) { |
664 | 664 |
|
665 | 665 | SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(exampleActor); |
666 | 666 |
|
667 | | - return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters); |
| 667 | + return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters); |
668 | 668 | }</programlisting> |
669 | 669 |
|
670 | 670 | <para>Remember that the |
@@ -860,7 +860,7 @@ public class RunAQuery { |
860 | 860 | } |
861 | 861 |
|
862 | 862 | public int getCount() { |
863 | | - return this.jdbcTemplate.queryForObject("select count(*) from mytable", int.class); |
| 863 | + return this.jdbcTemplate.queryForObject("select count(*) from mytable", Integer.class); |
864 | 864 | } |
865 | 865 |
|
866 | 866 | public String getName() { |
|
0 commit comments