Skip to content

Columns of the new MSSQL 2025 data type JSON are omitted during table schema discovery #2878

@sa-obgit-backend

Description

@sa-obgit-backend

Driver version
com.microsoft.sqlserver:mssql-jdbc:13.2.1.jre11

SQL Server version
SQL Server 2025 Standard Edition (17.0.1000.7)

Client Operating System
Ubuntu Linux, Microsoft Windows 11

JAVA/JVM version
Java 24

Table schema
CREATE TABLE [dbo].[sample](
[uuid] [uniqueidentifier] NOT NULL,
[accessible] [bit] NULL,
[context] varchar NULL,
[custom_id] varchar NULL,
[display_text] varchar NULL,
[merged_to] [uniqueidentifier] NULL,
[obguid] varchar NULL,
[data_id] [bigint] NULL,
[is_native] [bit] NULL,
[last_modified_at] datetimeoffset NULL,
[data_json] [json] NULL, <<< this is relevant
[created_at] datetimeoffset NULL,
[deactivated_at] datetimeoffset NULL,
[selectable] [bit] NULL
)

Database compatibility level
170 (MSSQL 2025)

Problem description
When discovering the columns and column types of the sample table, the column data_json is omitted and thus cannot be queried or worked with in general, leading to an error within Hibernate/JPA.

Root cause
When discovering the table schema the driver either executes sys.sp_columns or sys.sp_columns_100 respectively in the method DatabaseMetadata.getColumns() and thus the system stored procedure omits the column data_json which is of the new JSON data type.

Proposed solution
The driver should determine by the database compatibility level 170 that sys.sp_columns_170 should be used, which supports the column data_json and returns it with its respective type.

Metadata

Metadata

Assignees

Labels

Under ReviewUsed for pull requests under review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions