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

SimpleJdbcInsert should take Map<String, ?> as arg instead of Map<String, Object> [SPR-12462] #17067

Closed
spring-projects-issues opened this issue Nov 22, 2014 · 2 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

The Alchemist opened SPR-12462 and commented

Description

I would like to do something like:

SimpleJdbcInsert insert = new SimpleJdbcInsert(dataSource).withTableName("x");
Map<String, Number> args = new HashMap<>();
args.put("one", 1);
args.put("two", 2);
insert.setColumnNames(Arrays.asList("one", "two"));
insert.execute(args );

However, this doesn't work because SimpleJdbcInsertOperations takes Map<String, Object as an argument for its methods instead of Map<String, ?>.

GitHub Pull Request Link

#700


Affects: 4.1.2

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Fixed for 4.1.3 now, making it consistent with Map<String, ?> declarations in NamedParameterJdbcTemplate and many other places. It was simply an oversight that SimpleJdbcInsert was more restrictive there.

However, note that we are only doing this for incoming parameters (being lenient for what we accept) while we're still declaring concrete value types for Maps returned from Spring API methods.

While being at it, I've done a somewhat larger revision of related JDBC accessor code, e.g. also consistently using LinkedHashMap for adapting incoming parameters (preserving a user-specified order when coming from vararg arrays in particular, even if just for logging purposes).

Juergen

@spring-projects-issues
Copy link
Collaborator Author

The Alchemist commented

Thanks, Juergen Hoeller!

@spring-projects-issues spring-projects-issues added in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.3 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 Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants