[CONJ-908] Auto-generated keys are not returned if they're requested by column names or indexes Created: 2021-12-23  Updated: 2022-01-10  Resolved: 2022-01-10

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC compatibility
Affects Version/s: 3.0.2-rc
Fix Version/s: 3.0.3

Type: Bug Priority: Critical
Reporter: Oleg Alexeyev Assignee: Diego Dupin
Resolution: Fixed Votes: 1
Labels: None


 Description   

org.mariadb.jdbc.Connection.prepareStatement(String sql, int columnIndexes[]) and prepareStatement(String sql, String columnNames[]) call prepareStatement(sql), which in turn calls prepareInternal() with Statement.NO_GENERATED_KEYS, while it should request auto-generated keys using Statement.RETURN_GENERATED_KEYS.

Excerpt from JDBC Connection javadoc for these methods: "Creates a default PreparedStatement object capable of returning the auto-generated keys".

This leads to INSERTs to fail with SQLException: "Cannot return generated keys: query was not set with Statement.RETURN_GENERATED_KEYS".

In particular, this makes Spring JDBC SimpleJdbcInsert unusable as under the cover prepareStatement(String sql, String columnNames[]) gets called.



 Comments   
Comment by Diego Dupin [ 2022-01-10 ]

right, this has been already addressed with commit https://github.com/mariadb-corporation/mariadb-connector-j/commit/84f28a2f777220b4052bdc4c947f7caf79bec0db

Comment by Antonio Febles [ 2022-01-10 ]

Entiendo que esto está resuelto en la versión 3.0.3?

Generated at Thu Feb 08 03:19:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.