我有一個映射器的方法是這樣的:在SelectProvider中,MyBatis不允許多於一個參數嗎?
@InsertProvider(class=com.something.class, method="doSomething")
public void insertSomething(Set<Integer> set, int guideId);
,並在一些課,我有一個方法:
public String doSomething(Set<Integer> set, int guideId){
// do something and returna a query
}
它給了我一個錯誤:
錯誤創建SqlSource爲SqlProvider。法「DoSomething的」在sqlProvider的「com.something.class」
不 發現當我調試的問題。我發現,在ProviderSqlResource
構造函數,它會拋出這個異常,如果沒有。的論點是2 or more
。我想不出爲什麼他們會這麼做。什麼是解決方法?
這裏是方法:
public ProviderSqlSource(Configuration config, Object provider) {
String providerMethodName = null;
try {
this.sqlSourceParser = new SqlSourceBuilder(config);
this.providerType = (Class<?>) provider.getClass().getMethod("type").invoke(provider);
providerMethodName = (String) provider.getClass().getMethod("method").invoke(provider);
for (Method m : this.providerType.getMethods()) {
if (providerMethodName.equals(m.getName())) {
if (m.getParameterTypes().length < 2
&& m.getReturnType() == String.class) {
this.providerMethod = m;
this.providerTakesParameterObject = m.getParameterTypes().length == 1;
}
}
}
} catch (Exception e) {
throw new BuilderException("Error creating SqlSource for SqlProvider. Cause: " + e, e);
}
if (this.providerMethod == null) {
throw new BuilderException("Error creating SqlSource for SqlProvider. Method '"
+ providerMethodName + "' not found in SqlProvider '" + this.providerType.getName() + "'.");
}
}