Sql-java 的服务器 UniqueIntList 类型

Sql-Server UniqueIntList type for java

我有一个存储过程 (sp),它在 sql 服务器中使用 UniqueIntList 类型。我想使用 spring 的 NamedParameterJdbcTemplate 从 java 调用这个 sp。

sql 服务器 sp 执行详细信息

DECLARE @M dbo.UniqueIntList 
INSERT INTO @M VALUES (1),(2),(6)

exec usp_mysp @M

GO

下面是我如何使用 java

执行它
private static final String SQL_SP = "usp_mysp :myVar";
MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource();
    mapSqlParameterSource.addValue("myVar", myList); // my list is List<Integer>
    namedParameterJdbcTemplate.query(SQL_SP, mapSqlParameterSource, (q, i) -> {
        // ... //
    });

执行此操作时,我得到 过程或函数指定的参数过多,我发现这是由于 sql 服务器中的 UniqueIntList 类型造成的.

所以我想知道我究竟应该如何传递 NamedParameterJdbcTemplate 映射中的值?

正如@David Browne 在评论中所建议的那样,我对 Table 值参数进行了一些研究,这里的 Link 有助于理解如何使用 [=13= 实现它] 的 NamedParameterJdbcTemplate 用于 ms-sql 服务器