Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JdbcTemplate does not apply values of zero for setMaxRows, setFetchSize and setQueryTimeout [SPR-12338] #16943

Closed
spring-projects-issues opened this issue Oct 15, 2014 · 1 comment
Assignees
Labels
in: data type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 15, 2014

Robert Wruck opened SPR-12338 and commented

JdbcTemplate.applyStatementSettings does not apply values of 0 for setMaxRows, setFetchSize and setQueryTimeout. I assume this is because zero is the default value for these Statement properties.
On the other hand, zero is a legal value for all three properties and should not be silently ignored. Furthermore, connection pools such as C3P0 may cache Statement objects that had a nonzero value applied by a different JdbcTemplate. For such statements, not applying a zero value leads to unexpexted results (e.g. limited number of result rows vs. unlimited as requested by a value of 0 for maxRows).
I agree that if one of these properties was never set on the JdbcTemplate, the corresponding property should not be set on the Statement. But a (legal) value of 0 is not a good way of detecting that.


Affects: 4.1.1

Referenced from: commits 57d63a1

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 16, 2014

Juergen Hoeller commented

We expect a connection pool to reset those Statement settings when returning a Statement to the pool on logical close. It shouldn't be necessary to reset those settings in client code (like JdbcTemplate) since it makes the use of a statement pool non-transparent...

That said, you nevertheless have a point that it should be possible to explicitly set those settings to 0, for example to override a non-zero default value from a specific driver/pool. I'll turn this into a corresponding improvement issue, covering both JdbcTemplate and JmsTemplate.

The default values for those settings are simply -1 now, and we're passing >=0 on to the driver.

Juergen

@spring-projects-issues spring-projects-issues added in: data type: enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants