参数值 [0] 与预期类型 [java.lang.Integer] 不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31707504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 19:01:55  来源:igfitidea点击:

Parameter value [0] did not match expected type [java.lang.Integer]

javaspringjpastored-procedureshql

提问by Kingpin2k

Fun issue where I'm passing an intin and it's complaining about it not matching the type:

我传入一个有趣的问题,int它抱怨它与类型不匹配:

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [0] did not match expected type [java.lang.Integer]

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [0] did not match expected type [java.lang.Integer]

@Procedure(procedureName = "dbo.do_cool_stuff_to_client")
void coolClientStuff(int clientId);

It's being called like so:

它被这样调用:

public void someOtherMethod(int clientId){
  clientRepository.coolClientStuff(clientId);
}

回答by Kingpin2k

It turns out there is something stupid/funky with it, where it really wants me to put in the class type and not a primitive type.

事实证明它有一些愚蠢/时髦的东西,它真的希望我放入类类型而不是原始类型。

Changing the method signature to use Integerinstead of intfixed it.

更改方法签名以使用Integer而不是int修复它。

@Procedure(procedureName = "dbo.do_cool_stuff_to_client")
void coolClientStuff(Integer clientId);