micronaut-projects / micronaut-projects/micronaut-data

Batch insert for MSSQL

Open
#629 6 comments 0 reactions 0 assignees View on GitHub
type: improvement
Dominant language
Java
Stars
482
Forks
229
Avg merge
1d 7h
Merged PRs (30d)
32

Description

This issue doesn't fall into the issue template sorry, so I'll keep it short.

Micronaut Data disables batch insert capability for MSSQL ([code](https://github.com/micronaut-projects/micronaut-data/blob/60195d28198d90369999b02a4db4b9d4f58ef25e/data-jdbc/src/main/java/io/micronaut/data/jdbc/operations/AbstractSqlRepositoryOperations.java#L327)).

This is because MSSQL doesn't return generated primary keys for multiple inserts (I can reproduce this in plain JDBC). However, the batch insert functionality itself works fine in JDBC if you don't care about the returned IDs.

Could MSSQL batch inserts be enabled via a config flag like `micronaut.data.mssql-batch-inserts: true`? This gives users the choice.

I understand if this isn't worth the added complexity. Users can still use Micronaut for JDBC transactions and fall back to plain JDBC + JDBI or similar.

Contributor guide

Open the contributing guide

Research direction

Start with data-jdbc/src/main/java/io/micronaut/data/jdbc/operations/AbstractSqlRepositoryOperations.java around the batch-insert handling at line 327. Review the plain JDBC behavior described in the issue, especially the absence of generated IDs for multiple MSSQL inserts. Done means MSSQL batch inserts can be enabled through the proposed configuration option while preserving the existing default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.