Use 'Integer' not 'int' in queryForObject docs

Update queryForObject calls in the JDBC reference documentation to
use 'Integer.class' rather than the unsupported 'int.class'.

Issue: SPR-10651
master
Phillip Webb 11 years ago
parent 8ed8ee2dfe
commit c720d82596
  1. 12
      src/reference/docbook/jdbc.xml

@ -304,12 +304,12 @@
<para>Here is a simple query for getting the number of rows in a <para>Here is a simple query for getting the number of rows in a
relation:</para> relation:</para>
<programlisting language="java">int rowCount = this.jdbcTemplate.queryForObject("select count(*) from t_actor", int.class);</programlisting> <programlisting language="java">int rowCount = this.jdbcTemplate.queryForObject("select count(*) from t_actor", Integer.class);</programlisting>
<para>A simple query using a bind variable:</para> <para>A simple query using a bind variable:</para>
<programlisting language="java">int countOfActorsNamedJoe = this.jdbcTemplate.queryForObject( <programlisting language="java">int countOfActorsNamedJoe = this.jdbcTemplate.queryForObject(
"select count(*) from t_actor where first_name = ?", int.class, "Joe");</programlisting> "select count(*) from t_actor where first_name = ?", Integer.class, "Joe");</programlisting>
<para>Querying for a <classname>String</classname>:</para> <para>Querying for a <classname>String</classname>:</para>
@ -567,7 +567,7 @@ public int countOfActorsByFirstName(String firstName) {
SqlParameterSource namedParameters = new MapSqlParameterSource("first_name", firstName); SqlParameterSource namedParameters = new MapSqlParameterSource("first_name", firstName);
return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters); return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters);
}</programlisting> }</programlisting>
<para>Notice the use of the named parameter notation in the value <para>Notice the use of the named parameter notation in the value
@ -600,7 +600,7 @@ public int countOfActorsByFirstName(String firstName) {
Map&lt;String, String&gt; namedParameters = Collections.singletonMap("first_name", firstName); Map&lt;String, String&gt; namedParameters = Collections.singletonMap("first_name", firstName);
return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters); return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters);
}</programlisting> }</programlisting>
<para>One nice feature related to the <para>One nice feature related to the
@ -664,7 +664,7 @@ public int countOfActors(Actor exampleActor) {
SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(exampleActor); SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(exampleActor);
return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters); return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters);
}</programlisting> }</programlisting>
<para>Remember that the <para>Remember that the
@ -860,7 +860,7 @@ public class RunAQuery {
} }
public int getCount() { public int getCount() {
return this.jdbcTemplate.queryForObject("select count(*) from mytable", int.class); return this.jdbcTemplate.queryForObject("select count(*) from mytable", Integer.class);
} }
public String getName() { public String getName() {

Loading…
Cancel
Save