Myabtis-plus 非法参数异常 类型不匹配

问题:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property ‘id’ of ‘class com.ezerbel.mp.beans.Employee’ with value ‘1297717893730992130’ Cause: java.lang.IllegalArgumentException: argument type mismatch
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate S q l S e s s i o n I n t e r c e p t o r . i n v o k e ( S q l S e s s i o n T e m p l a t e . j a v a : 446 ) a t c o m . s u n . p r o x y . SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy. SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)atcom.sun.proxy.Proxy10.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy12.insert(Unknown Source)
at com.ezerbel.mp.test.TestMP.testCommonInsert(TestMP.java:27)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner 2. e v a l u a t e ( P a r e n t R u n n e r . j a v a : 222 ) a t o r g . j u n i t . r u n n e r s . P a r e n t R u n n e r . r u n ( P a r e n t R u n n e r . j a v a : 292 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t 4. r u n n e r . J U n i t 4 T e s t R e f e r e n c e . r u n ( J U n i t 4 T e s t R e f e r e n c e . j a v a : 86 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . T e s t E x e c u t i o n . r u n ( T e s t E x e c u t i o n . j a v a : 38 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n T e s t s ( R e m o t e T e s t R u n n e r . j a v a : 538 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n T e s t s ( R e m o t e T e s t R u n n e r . j a v a : 760 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . r u n ( R e m o t e T e s t R u n n e r . j a v a : 460 ) a t o r g . e c l i p s e . j d t . i n t e r n a l . j u n i t . r u n n e r . R e m o t e T e s t R u n n e r . m a i n ( R e m o t e T e s t R u n n e r . j a v a : 206 ) C a u s e d b y : o r g . a p a c h e . i b a t i s . r e f l e c t i o n . R e f l e c t i o n E x c e p t i o n : C o u l d n o t s e t p r o p e r t y ′ i d ′ o f ′ c l a s s c o m . e z e r b e l . m p . b e a n s . E m p l o y e e ′ w i t h v a l u e ′ 129771789373099213 0 ′ C a u s e : j a v a . l a n g . I l l e g a l A r g u m e n t E x c e p t i o n : a r g u m e n t t y p e m i s m a t c h a t o r g . a p a c h e . i b a t i s . r e f l e c t i o n . w r a p p e r . B e a n W r a p p e r . s e t B e a n P r o p e r t y ( B e a n W r a p p e r . j a v a : 185 ) a t o r g . a p a c h e . i b a t i s . r e f l e c t i o n . w r a p p e r . B e a n W r a p p e r . s e t ( B e a n W r a p p e r . j a v a : 59 ) a t o r g . a p a c h e . i b a t i s . r e f l e c t i o n . M e t a O b j e c t . s e t V a l u e ( M e t a O b j e c t . j a v a : 140 ) a t c o m . b a o m i d o u . m y b a t i s p l u s . M y b a t i s D e f a u l t P a r a m e t e r H a n d l e r . p o p u l a t e K e y s ( M y b a t i s D e f a u l t P a r a m e t e r H a n d l e r . j a v a : 217 ) a t c o m . b a o m i d o u . m y b a t i s p l u s . M y b a t i s D e f a u l t P a r a m e t e r H a n d l e r . p r o c e s s B a t c h ( M y b a t i s D e f a u l t P a r a m e t e r H a n d l e r . j a v a : 156 ) a t c o m . b a o m i d o u . m y b a t i s p l u s . M y b a t i s D e f a u l t P a r a m e t e r H a n d l e r . < i n i t > ( M y b a t i s D e f a u l t P a r a m e t e r H a n d l e r . j a v a : 71 ) a t c o m . b a o m i d o u . m y b a t i s p l u s . M y b a t i s X M L L a n g u a g e D r i v e r . c r e a t e P a r a m e t e r H a n d l e r ( M y b a t i s X M L L a n g u a g e D r i v e r . j a v a : 37 ) a t o r g . a p a c h e . i b a t i s . s e s s i o n . C o n f i g u r a t i o n . n e w P a r a m e t e r H a n d l e r ( C o n f i g u r a t i o n . j a v a : 545 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . B a s e S t a t e m e n t H a n d l e r . < i n i t > ( B a s e S t a t e m e n t H a n d l e r . j a v a : 69 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . P r e p a r e d S t a t e m e n t H a n d l e r . < i n i t > ( P r e p a r e d S t a t e m e n t H a n d l e r . j a v a : 40 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . R o u t i n g S t a t e m e n t H a n d l e r . < i n i t > ( R o u t i n g S t a t e m e n t H a n d l e r . j a v a : 46 ) a t o r g . a p a c h e . i b a t i s . s e s s i o n . C o n f i g u r a t i o n . n e w S t a t e m e n t H a n d l e r ( C o n f i g u r a t i o n . j a v a : 558 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . S i m p l e E x e c u t o r . d o U p d a t e ( S i m p l e E x e c u t o r . j a v a : 48 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . B a s e E x e c u t o r . u p d a t e ( B a s e E x e c u t o r . j a v a : 117 ) a t o r g . a p a c h e . i b a t i s . e x e c u t o r . C a c h i n g E x e c u t o r . u p d a t e ( C a c h i n g E x e c u t o r . j a v a : 76 ) a t o r g . a p a c h e . i b a t i s . s e s s i o n . d e f a u l t s . D e f a u l t S q l S e s s i o n . u p d a t e ( D e f a u l t S q l S e s s i o n . j a v a : 198 ) a t o r g . a p a c h e . i b a t i s . s e s s i o n . d e f a u l t s . D e f a u l t S q l S e s s i o n . i n s e r t ( D e f a u l t S q l S e s s i o n . j a v a : 185 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( U n k n o w n S o u r c e ) a t o r g . m y b a t i s . s p r i n g . S q l S e s s i o n T e m p l a t e 2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:292) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property 'id' of 'class com.ezerbel.mp.beans.Employee' with value '1297717893730992130' Cause: java.lang.IllegalArgumentException: argument type mismatch at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:185) at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:59) at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:140) at com.baomidou.mybatisplus.MybatisDefaultParameterHandler.populateKeys(MybatisDefaultParameterHandler.java:217) at com.baomidou.mybatisplus.MybatisDefaultParameterHandler.processBatch(MybatisDefaultParameterHandler.java:156) at com.baomidou.mybatisplus.MybatisDefaultParameterHandler.<init>(MybatisDefaultParameterHandler.java:71) at com.baomidou.mybatisplus.MybatisXMLLanguageDriver.createParameterHandler(MybatisXMLLanguageDriver.java:37) at org.apache.ibatis.session.Configuration.newParameterHandler(Configuration.java:545) at org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:69) at org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:40) at org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:46) at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:558) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198) at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185) 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.mybatis.spring.SqlSessionTemplate 2.evaluate(ParentRunner.java:222)atorg.junit.runners.ParentRunner.run(ParentRunner.java:292)atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)Causedby:org.apache.ibatis.reflection.ReflectionException:Couldnotsetpropertyidofclasscom.ezerbel.mp.beans.Employeewithvalue1297717893730992130Cause:java.lang.IllegalArgumentException:argumenttypemismatchatorg.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:185)atorg.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:59)atorg.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:140)atcom.baomidou.mybatisplus.MybatisDefaultParameterHandler.populateKeys(MybatisDefaultParameterHandler.java:217)atcom.baomidou.mybatisplus.MybatisDefaultParameterHandler.processBatch(MybatisDefaultParameterHandler.java:156)atcom.baomidou.mybatisplus.MybatisDefaultParameterHandler.<init>(MybatisDefaultParameterHandler.java:71)atcom.baomidou.mybatisplus.MybatisXMLLanguageDriver.createParameterHandler(MybatisXMLLanguageDriver.java:37)atorg.apache.ibatis.session.Configuration.newParameterHandler(Configuration.java:545)atorg.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:69)atorg.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:40)atorg.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:46)atorg.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:558)atorg.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:48)atorg.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)atorg.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)atorg.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)atorg.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.mybatis.spring.SqlSessionTemplateSqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
… 29 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
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.apache.ibatis.reflection.invoker.MethodInvoker.invoke(MethodInvoker.java:41)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:180)
… 50 more

解决:

指定主键策略

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值