Spring Integration存储过程参数中的空值

时间:2022-04-15 03:34:18

Is there a way to have Spring Integration call a stored procedure (that accepts an optional parameter) via its stored-proc-inbound-channel-adapter such that it passes either an int parameter or a null value, if the property for the corresponding parameter is not set? I have this in my config:

有没有办法让Spring Integration通过其stored-proc-inbound-channel-adapter调用存储过程(接受可选参数),以便传递int参数或null值,如果相应参数的属性没设定?我的配置中有这个:

<int-jdbc:parameter name="mykey" type="java.lang.Integer" value="${mykey:null}" />

But it gives me a TypeMisMatchException if mykey is not set because it tries to map null to an integer value (mykey would be passed to the Spring app as an optional parameter on the command line). I could go and change the default from null to 0 or so and change the stored proc to handle this, but wondering if there is a way to pass an actual null value. Do I need a different type or syntax?

但是如果没有设置mykey,它会给我一个TypeMisMatchException,因为它试图将null映射到整数值(mykey将作为命令行上的可选参数传递给Spring应用程序)。我可以将默认值从null更改为0左右并更改存储过程以处理此问题,但想知道是否有方法传递实际的空值。我需要不同的类型或语法吗?

1 个解决方案

#1


3  

Try

尝试

<int-jdbc:parameter name="mykey" type="java.lang.Integer" value="${mykey:#{null}}" /> 

#1


3  

Try

尝试

<int-jdbc:parameter name="mykey" type="java.lang.Integer" value="${mykey:#{null}}" />