Skip to content

Commit c720d82

Browse files
committed
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
1 parent 8ed8ee2 commit c720d82

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/reference/docbook/jdbc.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@
304304
<para>Here is a simple query for getting the number of rows in a
305305
relation:</para>
306306

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>
308308

309309
<para>A simple query using a bind variable:</para>
310310

311311
<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>
313313

314314
<para>Querying for a <classname>String</classname>:</para>
315315

@@ -567,7 +567,7 @@ public int countOfActorsByFirstName(String firstName) {
567567

568568
SqlParameterSource namedParameters = new MapSqlParameterSource("first_name", firstName);
569569

570-
return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters);
570+
return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters);
571571
}</programlisting>
572572

573573
<para>Notice the use of the named parameter notation in the value
@@ -600,7 +600,7 @@ public int countOfActorsByFirstName(String firstName) {
600600

601601
Map&lt;String, String&gt; namedParameters = Collections.singletonMap("first_name", firstName);
602602

603-
return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters);
603+
return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters);
604604
}</programlisting>
605605

606606
<para>One nice feature related to the
@@ -664,7 +664,7 @@ public int countOfActors(Actor exampleActor) {
664664

665665
SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(exampleActor);
666666

667-
return this.namedParameterJdbcTemplate.queryForObject(sql, int.class, namedParameters);
667+
return this.namedParameterJdbcTemplate.queryForObject(sql, Integer.class, namedParameters);
668668
}</programlisting>
669669

670670
<para>Remember that the
@@ -860,7 +860,7 @@ public class RunAQuery {
860860
}
861861

862862
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);
864864
}
865865

866866
public String getName() {

0 commit comments

Comments
 (0)