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

Support for named parameters in SimpleJdbcCall [SPR-12801] #17398

Closed
spring-issuemaster opened this issue Mar 10, 2015 · 10 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Mar 10, 2015

Kiril Nugmanov opened SPR-12801 and commented

org.springframework.jdbc.core.simple.AbstractJdbcCall uses org.springframework.jdbc.core.metadata.CallMetaDataContext to generate JDBC statement.

In case of Oracle PL/SQL org.springframework.jdbc.core.metadata.CallMetaDataContext.createCallString can be changed to support default values by implementing following changes in constructing JDBC statement from:

{call some_package.some_procedure(?,?,?)}

to

{call some_package.some_procedure(p_parameter_1 => ?, p_parameter_2 => ?, p_parameter_3 =>?)}

Change can be implemented in 2 ways:

  • modify org.springframework.jdbc.core.metadata.CallMetaDataContext in case if DB is Oracle
  • introduce setter for callMetaDataContext in org.springframework.jdbc.core.simple.AbstractJdbcCall then users can introduce it's own modification of org.springframework.jdbc.core.metadata.CallMetaDataContext

Related to #9084, #8193


Affects: 4.1.5

Reference URL: #763

Issue Links:

  • #8193 StoredProcedure enhancement to allow parameters to be optional
  • #9084 Support named parameters in CallableStatementCreator implementation

1 votes, 4 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 22, 2015

Serge Shikov commented

The same for MS SQL please. At the moment (in spring 3.x versions) the same call syntax is used, with positional parameters only:

{call sp(?,?,?)}

and it prevents us from using parameters defined with default values.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 26, 2015

Juergen Hoeller commented

We're considering this for 4.2 now. A pull request would be very much appreciated and would strongly increase the chances of this making it into 4.2 RC1!

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 29, 2015

Kiril Nugmanov commented

Created pull #763

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 12, 2015

Stéphane Nicoll commented

I have a candidate fix based on your PR and a few modifications (see this commit). I am still not sure if swapping the context is the right move.

You may want to review the Spring Framework Code Style as it contains valuable resources regarding the code format and the structure of the commit message.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 12, 2015

Kiril Nugmanov commented

Stéphane,

Can you explain why such swapping might be wrong?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 12, 2015

Stéphane Nicoll commented

Hey, I am not saying it's wrong. I am just confused about the approach of generating always "?" or always a named parameter for a given SimpleJdbcCall instance. I am not sure I actually fully understand how it's being used in practice.

What's wrong with adding the parameter always?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 12, 2015

Kiril Nugmanov commented

I think if you make named binding for Oracle/MS SQL as default for SimpleJdbcCall - previously working code might be broken. In existing code version there is no big deal how you name your parameters but in case of named parameters IS.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 12, 2015

Stéphane Nicoll commented

Gotcha. What's the problem of adding a setNamedBinding() on the existing CallMetadataContext and handle everything from there? There are already other setters on this class so if the idea is to either do everything with ? or do everything with parameter name, the existing class should be able to support both.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 12, 2015

Kiril Nugmanov commented

Adding setter in CallMetadataContext wont provide much flexibility. Moreover how you set namedBinding?

Current dependencies are following: AbstractJdbcCall<-CallMetaDataContext (CallMetaDataContext provided via constructor). So you need to create new instance of CallMetadataContext anyway and call setNamedBinding() on it.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 15, 2015

Stéphane Nicoll commented

Fixed in a slightly different way, adding the notion of named binding in the current CallMetadataContext instead of relying on an extension.

A new 4.2.0.BUILD-SNAPSHOT should be available in the next couple of hours. Please give that a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.