Class SqlServerJdbcSessionRepositoryDialect

java.lang.Object
org.springframework.ai.session.jdbc.SqlServerJdbcSessionRepositoryDialect
All Implemented Interfaces:
JdbcSessionRepositoryDialect

public class SqlServerJdbcSessionRepositoryDialect extends Object implements JdbcSessionRepositoryDialect
The dialect of Microsoft SQL Server (2016 and later).

The upsert and the insert-if-absent are a MERGE under HOLDLOCK, so that two concurrent saves of a new id cannot both take the insert branch. The lock covers the key range around the id and is held until the transaction ends: in a caller's transaction that stays open, an insert of another new id into that range and a write to the next session in key order wait for it. The insert-if-absent is not a plain INSERT, because its duplicate-key error would roll an enclosing transaction back on a connection with XACT_ABORT ON.

The timestamps and the metadata are cast so that a null expiry keeps its column type. The id is not: a cast silently cuts a value longer than its type, to the id of another session at worst, whereas the insert of an over-long id is rejected. SQL Server has no LIMIT; rows are limited with OFFSET ... FETCH.

Since:
2.1.0
Author:
Durga Dasepalli, Christian Tzolov