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 method names for lambdas [SPR-17148] #21685

Open
spring-projects-issues opened this issue Aug 8, 2018 · 1 comment
Open

JdbcTemplate method names for lambdas [SPR-17148] #21685

spring-projects-issues opened this issue Aug 8, 2018 · 1 comment
Labels
in: data status: waiting-for-triage

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 8, 2018

Alexandru-Constantin Bledea opened SPR-17148 and commented

I have encountered many times after changing the java8 code to use lambdas rather than strict objects that the compiler chooses the wrong method.

Because both RowCallbackHandler and ResultSetExtractor have the same lambda signature, the compiler can get confused sometimes and call the method that i wasn't intending to call.

I have found that in few places calls to jdbcTemplate.query(...,(rs) -> something(rs)) will be interpreted as calls to the RowCallbackHandler rather than ResultSetExtractor and there is no indication that this is happening.

Perhaps now with lambdas becoming more common place it would make sense to deprecate these methods and replace them with more explicit calls like queryWithHandler and queryWithExtractor so that we can be sure that we're calling the correct type?

 


No further details from SPR-17148

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 8, 2018

Alexandru-Constantin Bledea commented

I also want to add the fact that under normal circumstances the code works as expected, whenever the autodetection mechanism fails is because the applicatiion code is wrong (for instance returning void rather than Void)

But having explicit names would warn you immediately that you are doing it wrong and you would know to change the return type.

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

No branches or pull requests

1 participant