banner
RustyNail

RustyNail

coder. 【blog】https://rustynail.me 【nostr】wss://ts.relays.world/ wss://relays.world/nostr

【CrudBoy的奇妙冒險】跑了一年的程式碼報錯Invalid bound statement

跑了一年的程式碼報錯。。。

022-11-10 17:22:19.628 [http-nio-60051-exec-6] ERROR c.g.p.e.ExceptionProcessHandler - 無效的綁定語句(找不到):xx業務Mapper.selectBatchIds
org.apache.ibatis.binding.BindingException: 無效的綁定語句(找不到):xx業務Mapper.selectBatchIds
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.<init>(MybatisMapperMethod.java:50)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.lambda$cachedInvoker$0(MybatisMapperProxy.java:111)
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
	at com.baomidou.mybatisplus.core.toolkit.CollectionUtils.computeIfAbsent(CollectionUtils.java:115)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.cachedInvoker(MybatisMapperProxy.java:98)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
	at com.sun.proxy.$Proxy120.selectBatchIds(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:50)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy121.selectBatchIds(Unknown Source)

原本的程式碼

@DS("xxxx")
public List<xx業務> getxx業務s(List<Long> uid) {
	return xx業務Mapper.selectBatchIds(uid);
}

可能原因

1.mapper.xml 裡面的 namespace 與實際類別不一樣#

排查,一致

2.mapper 介面的函數名稱和 mapper.xml 裡面的標籤 id 不一致#

selectBatchIds 是 com.baomidou.mybatisplus.core.mapper.BaseMapper<xx 業務> 的預設方法

修復的程式碼

@DS("xxxx")
public List<xx業務> getxx業務s(List<Long> uid) {
		return  xx業務Mapper.selectList(new LambdaQueryWrapper<xx業務>()
			.in(xx業務::getUid, uid)
	);
}
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。