Hydrosan
Hydrosan

Reputation: 95

NamedParameterJdbcTemplate in Spring (3.0.5.RELEASE)

I'm trying to use this class but I can't seem to figure out how to limit the rows returned. Plain JdbcTemplate has a max row and max fetch size setter. Is there any way to get similar functionality out of NamedParameterJdbcTemplate ?

Upvotes: 1

Views: 4837

Answers (1)

axtavt
axtavt

Reputation: 242786

NamedParameterJdbcTemplate exposes its underlying JdbcTemplate via NamedParameterJdbcTemplate.getJdbcOperations():

((JdbcTemplate) namedParameterJdbcTemplate.getJdbcOperations()).setMaxRows(...);

Just for information: note that setMaxRows() shouldn't be used to set limits for individual queries (because NamedParameterJdbcTemplate is intended to be thread-safe, so that you shouldn't change its state after it have been initialized). Limits for individual queries are usually set by appropriate SQL clauses.

Upvotes: 6

Related Questions