[CONJ-1079] Batch insert not return generated key Created: 2023-05-17  Updated: 2023-06-07  Resolved: 2023-06-07

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 3.1.3, 3.1.4
Fix Version/s: 3.2.0

Type: Bug Priority: Major
Reporter: Rafael R Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: bug, generated, key

Attachments: PNG File Screenshot 2023-05-17 125504.png     PNG File Screenshot 2023-05-17 125735.png     PNG File Screenshot 2023-05-17 125848.png    

 Description   

When I do a batched insertion, if my first statement gives an error (like constraint violation), the rest of my insert result will not get the proper generated ID.

Debugging the connector, the OkPacket contains the ID, but because of that validation (see in attachment) none ID is returned.

My DataSource configuration have the following parameters:
"cachePrepStmts" , "true"
"cacheResultSetMetadata" , "true"
"cacheServerConfiguration" , "true"
"continueBatchOnError", "true"
"dontTrackOpenResources" , "true"
"dumpQueriesOnException", "true"
"elideSetAutoCommits" , "true"
"includeThreadDumpInDeadlockExceptions", "true"
"jdbcCompliantTruncation", "true"
"log", "DEBUG"
"maintainTimeStats" , "false"
"prepStmtCacheSize" , "250"
"prepStmtCacheSqlLimit" , "2048"
"rewriteBatchedStatements" , "true"
"useServerPrepStmts" , "true"
"useLocalSessionState" , "true"
"useAffectedRows", "true"
"useBatchMultiSend", "true")
"useBulkStmts", "true"



 Comments   
Comment by Diego Dupin [ 2023-06-07 ]

Thanks for reporting the error, correction will be release in 3.2.0.

(correction is actually available using snapshot version:

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>3.2.0-SNAPSHOT</version>
    </dependency>
</dependencies>

)

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