簡體   English   中英

Spring JPA 存儲過程具有空值?

[英]Spring JPA Stored Procedure with a null value?

我有一個存儲過程,它是從 JpaRepository 實現中調用的

@Repository
public interface DataMartRepo extends JpaRepository<DataMartDAO, String> {

    @Procedure(procedureName = "dbo.txn_ETL")
    public void txnETL(
        @Param("txId") String txId,
        @Param("inId") String inId,
        @Param("proc") String proc,
        @Param("qtys") String qtys);

現在,這工作正常,期待當“proc”為空值時,在這種情況下它會拋出異常:

SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/Authenticator] 
threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: 
    Error calling CallableStatement.getMoreResults; nested exception is org.hibernate.exception.GenericJDBCException: 
    Error calling CallableStatement.getMoreResults] with root cause
com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 3.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildParamTypeDefinitions(SQLServerPreparedStatement.java:260)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildPreparedStrings(SQLServerPreparedStatement.java:219)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doPrepExec(SQLServerPreparedStatement.java:612)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:400)
[...]

如何處理空值? 將所有字符串設置為 "" 不提供空插入。

看起來 SP 調用中具有空值的參數是未解決的問題。 請參閱https://hibernate.atlassian.net/browse/HHH-9007

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM