spring-projects / spring-projects/spring-data-relational

Enable Microsoft SQL Server Dialect to work with primary key default.

Open
#2,269 0 comments 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Mar 20, 2026.

type: enhancement
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

Currently the SqlServerDialect requires use of IDENTITY to retrieve inserted id values.

ID INT IDENTITY PRIMARY KEY

The above can be tricky when attempting to e.g. upsert values (see: #493) as it requires additional statements SET IDENTITY_INSERT <table_name> ON|OFF to allow inserting values into the ID column.

Using a different column declaration approach neglects the need of the additional identity insert instructions.

ID INT PRIMARY KEY DEFAULT (NEXT VALUE FOR <seqence_name>)

Unfortunately using key defaults does not return the obtained value unless explicitly advised using OUTPUT INSERTED.<column_name>.

The SqlServerDialect should allow users to choose their identity strategy based on which OUTPUT INSERTED is included in the statement or not.

Running additional commands to en/disable IDENTITY_INSERT before/after the statement is in the users responsibility when choosing IDENTITY. They should not be run by data-jdbc as part of an insert/upsert attempt.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.