gpt4 book ai didi

java - Spring JPA 存储过程具有空值?

转载 作者:行者123 更新时间:2023-11-30 07:25:37 27 4
gpt4 key购买 nike

我有一个存储过程,它是从 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

关于java - Spring JPA 存储过程具有空值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36844811/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com