Skip to content

Add support for SQL Server's INSERT … OUTPUT clause #577

Open
@vasilhsfoto

Description

@vasilhsfoto

Current setup

dependencies
spring boot v 2.4.3
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-r2dbc</artifactId> </dependency> <dependency> <groupId>io.r2dbc</groupId> <artifactId>r2dbc-mssql</artifactId> </dependency> <dependency> <groupId>io.r2dbc</groupId> <artifactId>r2dbc-pool</artifactId> </dependency>
Repository
ItemRepository extends ReactiveCrudRepository<Item, UUID>

DB schema in mssql server
[id] UNIQUEIDENTIFIER default NEWID(),
...
code
var itemToSave = new Item().setName(); RegistrationRoute newSavedEntity = itemRepo.save(itemToSave) .log() .block();
The entity is the same instance and the id is not populated.

Notes:
The above works as expected when running on H2 data base. Although the instance is mutated as opposed a brand new one to be created which I would expect.

The type of the id has the same behaviour declared either UUID or String. Which is as expected since the mapping between DB type and Java type comes from the mssql r2dbc driver which supports UUID/String -> uniqueIdentifier

Trying the varchar() (with auto generated GUID) -> String mapping for key. Still doesn't work
Trying the INT (with IDENTITY => autogenerate sequence)-> Integer/int mapping for key it does work as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions