使用你的mybatis插件 时候碰上一个问题

如是传统 发布于 2013/11/08 10:57
阅读 33K+
收藏 0

【深度】AI、5G时代下,算力网络与内生安全最全解析!>>>

@miemiedev 你好,想跟你请教个问题:这个分页插件用上后 我期望直接使用shopExample

PageBounds pgb = new PageBounds(1,30);
        ShopExample example = new ShopExample();
        example.setDistinct(false);
        example.createCriteria().andShopIdLessThan(BigDecimal.valueOf(30000));
        List<Shop> list = shopMapper.selectByExample(example,pgb);
        for(Shop ss : list){
            System.out.println(ss.getShopName());
        }
        PageList pageList = (PageList)list;
        System.out.println("totalCount: " + pageList.getPaginator().getTotalCount());

example.createCriteria().andShopIdLessThan(BigDecimal.valueOf(30000)); 不加时候是正常的

OffsetLimitInterceptor.java 123行 return 时候报错

        if(countTask!=null){
            Future<Paginator> countFutrue = call(countTask, async);
            return new PageList(listFuture.get(),countFutrue.get());
        }

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.reflect.UndeclaredThrowableException
### The error may exist in file [D:\JAVAEE\newversioneclipse\keplerwork\yiwugou\yiwugou-dao\target\classes\conf\mybatis\xml\ShopMapper.xml]
### The error may involve com.yiwugou.dao.repository.mybatis.shop.ShopMapper.selectByExample-Inline
### The error occurred while setting parameters
### SQL: select * from ( select                 SHOP_ID, SUPPLIER_ID, USER_ID, BOOTH_ID, SHOP_NAME, COMPANY_ID_OR_PERSON_ID, COMPANY_PERSON_TYPE,      MAIN_PRODUCT, COMPANY_URL, INTRODUCTION, PICTURE_URL_A, PICTURE_URL_SA, PICTURE_URL_B,      PICTURE_URL_SB, PICTURE_URL_C, PICTURE_URL_SC, MATING_SERVICE, CONTACTER, CONTACTER_PHOTO,      CONTACTER_PHOTO_S, TELEPHONE, MOBILE, TELEPHONE_SERVICE_FLAG, QQ, MSN, SALESMAN,      STATUS, CREATE_TIME, CREATE_USER, UPDATE_TIME, UPDATE_USER, SHOP_VERSION, MAININDUSTRY,      SAFEMOBILE, SIGNSTATUS, FRIENDPASSW, EMAIL, OLD_USER_ID, OLD_FLAG, OLD_IMPORT_FLAG,      GENERATEDATE, INTEGRITYSTATUS, TRANSLATE_ID, LONGITUDE, LATITUDE, SHOP_URL_ID, TRANSLATESTATUS,      SELL_RETAIL, CREDIT, SHOP3DURL, MARKETMANAGERID, INVESTIGATION, SHOP3DEDITURL, BOOTHIDS,      BOOTHAREA, SLOGAN, SHOP3DPASSWORD, NOTICE, INTEGRITY_FRACTION         from YIWUGOUTEST.T_SHOP                    WHERE (  SHOP_ID < ? ) ) where rownum <= 30
### Cause: java.lang.reflect.UndeclaredThrowableException
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
    at $Proxy16.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:202)
    at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:122)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:90)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
    at $Proxy17.selectByExample(Unknown Source)
    at com.yiwugou.dao.test.shop.ShopTestCase.testShopDao(ShopTestCase.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.reflect.UndeclaredThrowableException
### The error may exist in file [D:\JAVAEE\newversioneclipse\keplerwork\yiwugou\yiwugou-dao\target\classes\conf\mybatis\xml\ShopMapper.xml]
### The error may involve com.yiwugou.dao.repository.mybatis.shop.ShopMapper.selectByExample-Inline
### The error occurred while setting parameters
### SQL: select * from ( select                 SHOP_ID, SUPPLIER_ID, USER_ID, BOOTH_ID, SHOP_NAME, COMPANY_ID_OR_PERSON_ID, COMPANY_PERSON_TYPE,      MAIN_PRODUCT, COMPANY_URL, INTRODUCTION, PICTURE_URL_A, PICTURE_URL_SA, PICTURE_URL_B,      PICTURE_URL_SB, PICTURE_URL_C, PICTURE_URL_SC, MATING_SERVICE, CONTACTER, CONTACTER_PHOTO,      CONTACTER_PHOTO_S, TELEPHONE, MOBILE, TELEPHONE_SERVICE_FLAG, QQ, MSN, SALESMAN,      STATUS, CREATE_TIME, CREATE_USER, UPDATE_TIME, UPDATE_USER, SHOP_VERSION, MAININDUSTRY,      SAFEMOBILE, SIGNSTATUS, FRIENDPASSW, EMAIL, OLD_USER_ID, OLD_FLAG, OLD_IMPORT_FLAG,      GENERATEDATE, INTEGRITYSTATUS, TRANSLATE_ID, LONGITUDE, LATITUDE, SHOP_URL_ID, TRANSLATESTATUS,      SELL_RETAIL, CREDIT, SHOP3DURL, MARKETMANAGERID, INVESTIGATION, SHOP3DEDITURL, BOOTHIDS,      BOOTHAREA, SLOGAN, SHOP3DPASSWORD, NOTICE, INTEGRITY_FRACTION         from YIWUGOUTEST.T_SHOP                    WHERE (  SHOP_ID < ? ) ) where rownum <= 30
### Cause: java.lang.reflect.UndeclaredThrowableException
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
    ... 35 more
Caused by: java.lang.reflect.UndeclaredThrowableException
    at $Proxy20.query(Unknown Source)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)
    ... 40 more
Caused by: java.util.concurrent.ExecutionException: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_criterion_1' in 'class com.yiwugou.dao.entity.shop.ShopExample'
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor.intercept(OffsetLimitInterceptor.java:123)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57)
    ... 42 more
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_criterion_1' in 'class com.yiwugou.dao.entity.shop.ShopExample'
    at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333)
    at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:160)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:151)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:44)
    at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:123)
    at org.apache.ibatis.reflection.MetaObject.metaObjectForProperty(MetaObject.java:145)
    at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116)
    at com.github.miemiedev.mybatis.paginator.support.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:74)
    at com.github.miemiedev.mybatis.paginator.support.SQLHelp.getCount(SQLHelp.java:66)
    at com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor$1.call(OffsetLimitInterceptor.java:96)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor.call(OffsetLimitInterceptor.java:134)
    at com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor.intercept(OffsetLimitInterceptor.java:122)
    ... 43 more

加载中
1
miemiedev
miemiedev

问题已经解决,修改后的1.2.8版本已经可以在maven中央库找到了。

江安河的鱼
江安河的鱼
回复 @桂工移动我不动 : 换成1.2.8可以解决这个问题,但引出了跟多的问题(个人而言)。最后改用mybatis pagehelper了
桂工移动我不动
桂工移动我不动
回复 @江安河的鱼 : 请问解决这个问题了吗》?想请教一下
江安河的鱼
江安河的鱼
同 许可军 1.2.17还是有这个问题
J
Justin_Xu
1.2.17还是有这个问题,但是我用1.2.8试了一下,却没有这个问题。
0
miemiedev
miemiedev

 Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_criterion_1' in 'class com.yiwugou.dao.entity.shop.ShopExample'

你看一下你的mapper xml里的sql参数属性名有没有写错。

0
如是传统

@miemiedev 谢谢你的回复.ShopExample 这个是用官方的生成功具生成的 mapper.xml也是官方生成的 我的想法是这样 直接使用官方生成的xml不作变动 然后在

public interface BaseMapper<T> {

    List selectByExample(Object obj,PageBounds pageBounds);
}

定义这么一个分页辅助根接口

我试过了

 example.createCriteria().andShopIdLessThan(BigDecimal.valueOf(30000));

这个条件不加的时候是可以正确分页 这个条件加了后就报上面的错误了

日志中 输出的sql已经是正确的 断点 那个listFuture里面也已经有值了。

     if(countTask!=null){
            Future<Paginator> countFutrue = call(countTask, async);
            return new PageList(listFuture.get(),countFutrue.get());
        }

countFuture也正确执 在return 时候就报错了。countFutrue 里面报错了


0
miemiedev
miemiedev

为了能尽快的给你解决问题我觉得最好把你的QQ或者什么的联系方式私信给我,详细的说明一下。

0
如是传统
@miemiedev qq:65836307 邮箱 :snygaje@163.com  这里留言需要头像 不知道开源中国的私信如何发
返回顶部
顶部