• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ProviderSqlSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.ibatis.builder.annotation.ProviderSqlSource的典型用法代码示例。如果您正苦于以下问题:Java ProviderSqlSource类的具体用法?Java ProviderSqlSource怎么用?Java ProviderSqlSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProviderSqlSource类属于org.apache.ibatis.builder.annotation包,在下文中一共展示了ProviderSqlSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSqlSourceFromAnnotations

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
    try {
        Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
        Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
        if (sqlAnnotationType != null) {
            if (sqlProviderAnnotationType != null) {
                throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
            }
            Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
            final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
            return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
        } else if (sqlProviderAnnotationType != null) {
            Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
            return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation);
        }
        return null;
    } catch (Exception e) {
        throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:21,代码来源:MybatisMapperAnnotationBuilder.java


示例2: processConfiguration

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
/**
 * 配置指定的接口
 *
 * @param configuration
 * @param mapperInterface
 */
public void processConfiguration(Configuration configuration, Class<?> mapperInterface) {
    String prefix;
    if (mapperInterface != null) {
        prefix = mapperInterface.getCanonicalName();
    } else {
        prefix = "";
    }
    for (Object object : new ArrayList<Object>(configuration.getMappedStatements())) {
        if (object instanceof MappedStatement) {
            MappedStatement ms = (MappedStatement) object;
            if (ms.getId().startsWith(prefix) && isMapperMethod(ms.getId())) {
                if (ms.getSqlSource() instanceof ProviderSqlSource) {
                    setSqlSource(ms);
                }
            }
        }
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:25,代码来源:MapperHelper.java


示例3: getSqlSourceFromAnnotations

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
    try {
        Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
        Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
        if (sqlAnnotationType != null) {
            if (sqlProviderAnnotationType != null) {
                throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
            }
            Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
            final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
            return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
        } else if (sqlProviderAnnotationType != null) {
            Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
            return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
        }
        return null;
    } catch (Exception e) {
        throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:21,代码来源:MybatisMapperAnnotationBuilder.java


示例4: processMappedStatement

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
/**
 * 修改SqlSource
 *
 * @param ms
 * @throws Throwable
 */
public void processMappedStatement(MappedStatement ms) throws Throwable {
    SqlSource sqlSource = ms.getSqlSource();
    MetaObject msObject = SystemMetaObject.forObject(ms);
    SqlSource pageSqlSource;
    if (sqlSource instanceof StaticSqlSource) {
        pageSqlSource = new PageStaticSqlSource((StaticSqlSource) sqlSource);
    } else if (sqlSource instanceof RawSqlSource) {
        pageSqlSource = new PageRawSqlSource((RawSqlSource) sqlSource);
    } else if (sqlSource instanceof ProviderSqlSource) {
        pageSqlSource = new PageProviderSqlSource((ProviderSqlSource) sqlSource);
    } else if (sqlSource instanceof DynamicSqlSource) {
        pageSqlSource = new PageDynamicSqlSource((DynamicSqlSource) sqlSource);
    } else {
        throw new RuntimeException("无法处理该类型[" + sqlSource.getClass() + "]的SqlSource");
    }
    msObject.setValue("sqlSource", pageSqlSource);
    //由于count查询需要修改返回值,因此这里要创建一个Count查询的MS
    msCountMap.put(ms.getId(), MSUtils.newCountMappedStatement(ms));
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:26,代码来源:SqlUtil.java


示例5: methodNotFound

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void methodNotFound() throws NoSuchMethodException {
  expectedException.expect(BuilderException.class);
  expectedException.expectMessage(is("Error creating SqlSource for SqlProvider. Method 'methodNotFound' not found in SqlProvider 'org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder'."));
  new ProviderSqlSource(new Configuration(),
          ErrorMapper.class.getMethod("methodNotFound").getAnnotation(SelectProvider.class));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:SqlProviderTest.java


示例6: methodOverload

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void methodOverload() throws NoSuchMethodException {
  expectedException.expect(BuilderException.class);
  expectedException.expectMessage(is("Error creating SqlSource for SqlProvider. Method 'overload' is found multiple in SqlProvider 'org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder'. Sql provider method can not overload."));
  new ProviderSqlSource(new Configuration(),
          ErrorMapper.class.getMethod("methodOverload", String.class).getAnnotation(SelectProvider.class));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:SqlProviderTest.java


示例7: notSupportParameterObjectOnMultipleArguments

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void notSupportParameterObjectOnMultipleArguments() throws NoSuchMethodException {
  expectedException.expect(BuilderException.class);
  expectedException.expectMessage(is("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameQuery). Cannot invoke a method that holds multiple arguments using a specifying parameterObject. In this case, please specify a 'java.util.Map' object."));
  new ProviderSqlSource(new Configuration(),
          Mapper.class.getMethod("getUsersByName", String.class, String.class).getAnnotation(SelectProvider.class))
          .getBoundSql(new Object());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:SqlProviderTest.java


示例8: notSupportParameterObjectOnNamedArgument

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void notSupportParameterObjectOnNamedArgument() throws NoSuchMethodException {
  expectedException.expect(BuilderException.class);
  expectedException.expectMessage(is("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameWithParamNameQuery). Cannot invoke a method that holds named argument(@Param) using a specifying parameterObject. In this case, please specify a 'java.util.Map' object."));
  new ProviderSqlSource(new Configuration(),
          Mapper.class.getMethod("getUsersByNameWithParamName", String.class).getAnnotation(SelectProvider.class))
          .getBoundSql(new Object());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:SqlProviderTest.java


示例9: invokeError

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void invokeError() throws NoSuchMethodException {
  expectedException.expect(BuilderException.class);
  expectedException.expectMessage(is("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invokeError).  Cause: java.lang.reflect.InvocationTargetException"));
  new ProviderSqlSource(new Configuration(),
          ErrorMapper.class.getMethod("invokeError").getAnnotation(SelectProvider.class))
          .getBoundSql(new Object());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:SqlProviderTest.java


示例10: PageProviderSqlSource

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
public PageProviderSqlSource(ProviderSqlSource provider) {
    MetaObject metaObject = SystemMetaObject.forObject(provider);
    this.sqlSourceParser = (SqlSourceBuilder) metaObject.getValue("sqlSourceParser");
    this.providerType = (Class<?>) metaObject.getValue("providerType");
    this.providerMethod = (Method) metaObject.getValue("providerMethod");
    this.configuration = (Configuration) metaObject.getValue("sqlSourceParser.configuration");
    try {
        //先针对3.3.1和之前版本做判断
        this.providerTakesParameterObject = (Boolean) metaObject.getValue("providerTakesParameterObject");
    } catch (ReflectionException e) {
        //3.4.0+版本,解决#102 by Ian Lim
        providerMethodArgumentNames = (String[]) metaObject.getValue("providerMethodArgumentNames");
    }
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:15,代码来源:PageProviderSqlSource.java


示例11: processMappedStatement

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
/**
 * 处理 MappedStatement
 *
 * @param ms
 */
public void processMappedStatement(MappedStatement ms){
    MapperTemplate mapperTemplate = isMapperMethod(ms.getId());
    if(mapperTemplate != null && ms.getSqlSource() instanceof ProviderSqlSource) {
        setSqlSource(ms, mapperTemplate);
    }
}
 
开发者ID:abel533,项目名称:Mapper,代码行数:12,代码来源:MapperHelper.java


示例12: methodNotFound

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void methodNotFound() throws NoSuchMethodException {
  try {
    Class<?> mapperType = ErrorMapper.class;
    Method mapperMethod = mapperType.getMethod("methodNotFound");
    new ProviderSqlSource(new Configuration(),
          mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod);
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error creating SqlSource for SqlProvider. Method 'methodNotFound' not found in SqlProvider 'org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder'."));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:13,代码来源:SqlProviderTest.java


示例13: methodOverload

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void methodOverload() throws NoSuchMethodException {
  try {
    Class<?> mapperType = ErrorMapper.class;
    Method mapperMethod = mapperType.getMethod("methodOverload", String.class);
    new ProviderSqlSource(new Configuration(),
            mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod);
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error creating SqlSource for SqlProvider. Method 'overload' is found multiple in SqlProvider 'org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder'. Sql provider method can not overload."));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:13,代码来源:SqlProviderTest.java


示例14: notSqlProvider

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void notSqlProvider() throws NoSuchMethodException {
  try {
    new ProviderSqlSource(new Configuration(), new Object(), null, null);
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error creating SqlSource for SqlProvider.  Cause: java.lang.NoSuchMethodException: java.lang.Object.type()"));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:10,代码来源:SqlProviderTest.java


示例15: multipleProviderContext

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void multipleProviderContext() throws NoSuchMethodException {
  try {
    Class<?> mapperType = ErrorMapper.class;
    Method mapperMethod = mapperType.getMethod("multipleProviderContext");
    new ProviderSqlSource(new Configuration(),
          mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod);
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error creating SqlSource for SqlProvider. ProviderContext found multiple in SqlProvider method (org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.multipleProviderContext). ProviderContext can not define multiple in SqlProvider method argument."));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:13,代码来源:SqlProviderTest.java


示例16: notSupportParameterObjectOnMultipleArguments

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void notSupportParameterObjectOnMultipleArguments() throws NoSuchMethodException {
  try {
    Class<?> mapperType = Mapper.class;
    Method mapperMethod = mapperType.getMethod("getUsersByName", String.class, String.class);
    new ProviderSqlSource(new Configuration(),
          mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod)
            .getBoundSql(new Object());
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameQuery). Cannot invoke a method that holds multiple arguments using a specifying parameterObject. In this case, please specify a 'java.util.Map' object."));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:14,代码来源:SqlProviderTest.java


示例17: notSupportParameterObjectOnNamedArgument

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void notSupportParameterObjectOnNamedArgument() throws NoSuchMethodException {
  try {
    Class<?> mapperType = Mapper.class;
    Method mapperMethod = mapperType.getMethod("getUsersByNameWithParamName", String.class);
    new ProviderSqlSource(new Configuration(),
          mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod)
            .getBoundSql(new Object());
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.OurSqlBuilder.buildGetUsersByNameWithParamNameQuery). Cannot invoke a method that holds named argument(@Param) using a specifying parameterObject. In this case, please specify a 'java.util.Map' object."));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:14,代码来源:SqlProviderTest.java


示例18: invokeError

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void invokeError() throws NoSuchMethodException {
  try {
    Class<?> mapperType = ErrorMapper.class;
    Method mapperMethod = mapperType.getMethod("invokeError");
    new ProviderSqlSource(new Configuration(),
          mapperMethod.getAnnotation(SelectProvider.class), mapperType, mapperMethod)
            .getBoundSql(new Object());
    fail();
  } catch (BuilderException e) {
    assertTrue(e.getMessage().contains("Error invoking SqlProvider method (org.apache.ibatis.submitted.sqlprovider.SqlProviderTest$ErrorSqlBuilder.invokeError).  Cause: java.lang.reflect.InvocationTargetException"));
  }
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:14,代码来源:SqlProviderTest.java


示例19: MyProviderSqlSource

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
private MyProviderSqlSource(Configuration configuration, ProviderSqlSource providerSqlSource, Boolean count) {
    this.configuration = configuration;
    this.providerSqlSource = providerSqlSource;
    this.count = count;
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:6,代码来源:SqlUtil.java


示例20: notSqlProvider

import org.apache.ibatis.builder.annotation.ProviderSqlSource; //导入依赖的package包/类
@Test
public void notSqlProvider() throws NoSuchMethodException {
  expectedException.expect(BuilderException.class);
  expectedException.expectMessage(is("Error creating SqlSource for SqlProvider.  Cause: java.lang.NoSuchMethodException: java.lang.Object.type()"));
  new ProviderSqlSource(new Configuration(), new Object());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:7,代码来源:SqlProviderTest.java



注:本文中的org.apache.ibatis.builder.annotation.ProviderSqlSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PGPSignatureSubpacketVector类代码示例发布时间:2022-05-22
下一篇:
Java DefaultMultiValueCategoryDataset类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap