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

Java DBType类代码示例

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

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



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

示例1: intercept

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
public Object intercept(Invocation invocation) throws Throwable {
    /**
     * 处理 DELETE UPDATE 语句
     */
    MappedStatement ms = (MappedStatement) invocation.getArgs()[0];
    if (ms.getSqlCommandType() == SqlCommandType.DELETE || ms.getSqlCommandType() == SqlCommandType.UPDATE) {
        Executor executor = (Executor) invocation.getTarget();
        Configuration configuration = ms.getConfiguration();
        Object parameter = invocation.getArgs()[1];
        BoundSql boundSql = ms.getBoundSql(parameter);
        Connection connection = executor.getTransaction().getConnection();
        String databaseVersion = connection.getMetaData().getDatabaseProductVersion();
        if (GlobalConfigUtils.getDbType(configuration).equals(DBType.MYSQL)
                && VersionUtils.compare(minMySQLVersion, databaseVersion)) {
            logger.warn("Warn: Your mysql version needs to be greater than '5.6.3' to execute of Sql Explain!");
            return invocation.proceed();
        }
        /**
         * 执行 SQL 分析
         */
        sqlExplain(configuration, ms, boundSql, connection, parameter);
    }
    return invocation.proceed();
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:25,代码来源:SqlExplainInterceptor.java


示例2: getiDialect

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 获取数据库方言
 * </p>
 *
 * @param dbType       数据库类型
 * @param dialectClazz 自定义方言实现类
 * @return
 * @throws Exception
 */
private static IDialect getiDialect(DBType dbType, String dialectClazz) throws Exception {
    IDialect dialect = null;
    if (Objects.nonNull(dbType)) {
        dialect = getDialectByDbtype(dbType);
    } else {
        if (StringUtils.isNotEmpty(dialectClazz)) {
            try {
                Class<?> clazz = Class.forName(dialectClazz);
                if (IDialect.class.isAssignableFrom(clazz)) {
                    dialect = (IDialect) clazz.newInstance();
                }
            } catch (ClassNotFoundException e) {
                throw new MybatisPlusException("Class :" + dialectClazz + " is not found");
            }
        }
    }
    /* 未配置方言则抛出异常 */
    if (dialect == null) {
        throw new MybatisPlusException("The value of the dialect property in mybatis configuration.xml is not defined.");
    }
    return dialect;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:33,代码来源:DialectFactory.java


示例3: getDialectByDbtype

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 根据数据库类型选择不同分页方言
 * </p>
 *
 * @param dbType 数据库类型
 * @return
 * @throws Exception
 */
private static IDialect getDialectByDbtype(DBType dbType) {
    switch (dbType) {
        case MYSQL:
            return MySqlDialect.INSTANCE;
        case ORACLE:
            return OracleDialect.INSTANCE;
        case DB2:
            return DB2Dialect.INSTANCE;
        case H2:
            return H2Dialect.INSTANCE;
        case SQLSERVER:
            return SQLServerDialect.INSTANCE;
        case SQLSERVER2005:
            return SQLServer2005Dialect.INSTANCE;
        case POSTGRE:
            return PostgreDialect.INSTANCE;
        case HSQL:
            return HSQLDialect.INSTANCE;
        case SQLITE:
            return SQLiteDialect.INSTANCE;
        default:
            throw new MybatisPlusException("Error: Unknown database type, or do not support changing database!\n");
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:34,代码来源:DialectFactory.java


示例4: getDialect

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 获取数据库方言
 * </p>
 *
 * @param dbType       数据库类型
 * @param dialectClazz 自定义方言实现类
 * @return
 * @throws Exception
 */
private static IDialect getDialect(DBType dbType, String dialectClazz) throws Exception {
    IDialect dialect = null;
    if (StringUtils.isNotEmpty(dialectClazz)) {
        try {
            Class<?> clazz = Class.forName(dialectClazz);
            if (IDialect.class.isAssignableFrom(clazz)) {
                dialect = (IDialect) clazz.newInstance();
            }
        } catch (ClassNotFoundException e) {
            throw new MybatisPlusException("Class :" + dialectClazz + " is not found");
        }
    } else if (null != dbType) {
        dialect = getDialectByDbtype(dbType);
    }
    /* 未配置方言则抛出异常 */
    if (dialect == null) {
        throw new MybatisPlusException("The value of the dialect property in mybatis configuration.xml is not defined.");
    }
    return dialect;
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:31,代码来源:DialectFactory.java


示例5: intercept

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
    /**
     * 处理 DELETE UPDATE 语句
     */
    MappedStatement ms = (MappedStatement) invocation.getArgs()[0];
    if (ms.getSqlCommandType() == SqlCommandType.DELETE || ms.getSqlCommandType() == SqlCommandType.UPDATE) {
        Executor executor = (Executor) invocation.getTarget();
        Configuration configuration = ms.getConfiguration();
        Object parameter = invocation.getArgs()[1];
        BoundSql boundSql = ms.getBoundSql(parameter);
        Connection connection = executor.getTransaction().getConnection();
        String databaseVersion = connection.getMetaData().getDatabaseProductVersion();
        if (GlobalConfigUtils.getDbType(configuration).equals(DBType.MYSQL)
                && VersionUtils.compare(minMySQLVersion, databaseVersion)) {
            logger.warn("Warn: Your mysql version needs to be greater than '5.6.3' to execute of Sql Explain!");
            return invocation.proceed();
        }
        /**
         * 执行 SQL 分析
         */
        sqlExplain(configuration, ms, boundSql, connection, parameter);
    }
    return invocation.proceed();
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:26,代码来源:SqlExplainInterceptor.java


示例6: getAs

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
public String getAs() {
    if (StringUtils.isEmpty(getColumn()) || StringUtils.isEmpty(as)) {
        return StringUtils.EMPTY;
    }
    String quote = null;
    if (isEscape() && FACTORY != null) {
        GlobalConfiguration globalConfig = GlobalConfigUtils.getGlobalConfig(FACTORY.getConfiguration());
        quote = globalConfig.getIdentifierQuote() == null ? DBType.getQuote(globalConfig.getDbType()) : globalConfig.getIdentifierQuote();
    }
    return AS + (StringUtils.isNotEmpty(quote) ? String.format(quote, as) : as);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:12,代码来源:Column.java


示例7: getDbType

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 根据连接地址判断数据库类型
 * </p>
 *
 * @param jdbcUrl 连接地址
 * @return
 */
public static DBType getDbType(String jdbcUrl) {
    if (StringUtils.isEmpty(jdbcUrl)) {
        return DBType.MYSQL;
    }
    if (jdbcUrl.startsWith("jdbc:mysql:") || jdbcUrl.startsWith("jdbc:cobar:")
            || jdbcUrl.startsWith("jdbc:log4jdbc:mysql:")) {
        return DBType.MYSQL;
    } else if (jdbcUrl.startsWith("jdbc:oracle:") || jdbcUrl.startsWith("jdbc:log4jdbc:oracle:")) {
        return DBType.ORACLE;
    } else if (jdbcUrl.startsWith("jdbc:microsoft:") || jdbcUrl.startsWith("jdbc:log4jdbc:microsoft:")) {
        return DBType.SQLSERVER;
    } else if (jdbcUrl.startsWith("jdbc:sqlserver:") || jdbcUrl.startsWith("jdbc:log4jdbc:sqlserver:")) {
        return DBType.SQLSERVER;
    } else if (jdbcUrl.startsWith("jdbc:postgresql:") || jdbcUrl.startsWith("jdbc:log4jdbc:postgresql:")) {
        return DBType.POSTGRE;
    } else if (jdbcUrl.startsWith("jdbc:hsqldb:") || jdbcUrl.startsWith("jdbc:log4jdbc:hsqldb:")) {
        return DBType.HSQL;
    } else if (jdbcUrl.startsWith("jdbc:db2:")) {
        return DBType.DB2;
    } else if (jdbcUrl.startsWith("jdbc:sqlite:")) {
        return DBType.SQLITE;
    } else if (jdbcUrl.startsWith("jdbc:h2:") || jdbcUrl.startsWith("jdbc:log4jdbc:h2:")) {
        return DBType.H2;
    } else {
        throw new MybatisPlusException("Error: Unknown database type, or do not support changing database!\n");
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:36,代码来源:JdbcUtils.java


示例8: intercept

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
   * Physical Pagination Interceptor for all the queries with parameter {@link org.apache.ibatis.session.RowBounds}
   */
  public Object intercept(Invocation invocation) throws Throwable {
      StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
      MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler);
      // 先判断是不是SELECT操作
      MappedStatement mappedStatement = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement");
      if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) {
          return invocation.proceed();
      }
      RowBounds rowBounds = (RowBounds) metaStatementHandler.getValue("delegate.rowBounds");
      /* 不需要分页的场合 */
      if (rowBounds == null || rowBounds == RowBounds.DEFAULT) {
          return invocation.proceed();
      }
      BoundSql boundSql = (BoundSql) metaStatementHandler.getValue("delegate.boundSql");
      String originalSql = boundSql.getSql();
      Connection connection = (Connection) invocation.getArgs()[0];
      DBType dbType = JdbcUtils.getDbType(connection.getMetaData().getURL());
      if (rowBounds instanceof Pagination) {
          Pagination page = (Pagination) rowBounds;
          if (page.isSearchCount()) {
              this.queryTotal(JsqlParserUtils.jsqlparserCount(originalSql), mappedStatement, boundSql, page, connection);
              if (page.getTotal() <= 0) {
                  return invocation.proceed();
              }
          }
          originalSql = DialectFactory.buildPaginationSql(page, originalSql, dbType, null);
      } else {
          // support physical Pagination for RowBounds
          originalSql = DialectFactory.buildPaginationSql(rowBounds, originalSql, dbType, null);
      }

/*
       * <p> 禁用内存分页 </p> <p> 内存分页会查询所有结果出来处理(这个很吓人的),如果结果变化频繁这个数据还会不准。</p>
 */
      metaStatementHandler.setValue("delegate.boundSql.sql", originalSql);
      metaStatementHandler.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
      metaStatementHandler.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);
      return invocation.proceed();
  }
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:43,代码来源:PaginationInterceptor.java


示例9: getDialectByDbtype

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 根据数据库类型选择不同分页方言
 * </p>
 *
 * @param dbType 数据库类型
 * @return
 * @throws Exception
 */
private static IDialect getDialectByDbtype(DBType dbType) {
    IDialect dialect;
    switch (dbType) {
        case MYSQL:
            dialect = MySqlDialect.INSTANCE;
            break;
        case ORACLE:
            dialect = OracleDialect.INSTANCE;
            break;
        case DB2:
            dialect = DB2Dialect.INSTANCE;
            break;
        case H2:
            dialect = H2Dialect.INSTANCE;
            break;
        case SQLSERVER:
            dialect = SQLServerDialect.INSTANCE;
            break;
        case SQLSERVER2005:
            dialect = SQLServer2005Dialect.INSTANCE;
            break;
        case POSTGRE:
            dialect = PostgreDialect.INSTANCE;
            break;
        case HSQL:
            dialect = HSQLDialect.INSTANCE;
            break;
        case SQLITE:
            dialect = SQLiteDialect.INSTANCE;
            break;
        default:
            throw new MybatisPlusException("The Database's Not Supported! DBType:" + dbType);
    }
    return dialect;
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:45,代码来源:DialectFactory.java


示例10: getDbType

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 根据连接地址判断数据库类型
 * </p>
 *
 * @param jdbcUrl 连接地址
 * @return
 */
public static DBType getDbType(String jdbcUrl) {
    if (StringUtils.isEmpty(jdbcUrl)) {
        throw new MybatisPlusException("Error: The jdbcUrl is Null, Cannot read database type");
    }
    if (jdbcUrl.startsWith("jdbc:mysql:") || jdbcUrl.startsWith("jdbc:cobar:")
            || jdbcUrl.startsWith("jdbc:log4jdbc:mysql:")) {
        return DBType.MYSQL;
    } else if (jdbcUrl.startsWith("jdbc:oracle:") || jdbcUrl.startsWith("jdbc:log4jdbc:oracle:")) {
        return DBType.ORACLE;
    } else if (jdbcUrl.startsWith("jdbc:sqlserver:") || jdbcUrl.startsWith("jdbc:microsoft:")) {
        return DBType.SQLSERVER2005;
    } else if (jdbcUrl.startsWith("jdbc:sqlserver2012:")) {
        return DBType.SQLSERVER;
    } else if (jdbcUrl.startsWith("jdbc:postgresql:") || jdbcUrl.startsWith("jdbc:log4jdbc:postgresql:")) {
        return DBType.POSTGRE;
    } else if (jdbcUrl.startsWith("jdbc:hsqldb:") || jdbcUrl.startsWith("jdbc:log4jdbc:hsqldb:")) {
        return DBType.HSQL;
    } else if (jdbcUrl.startsWith("jdbc:db2:")) {
        return DBType.DB2;
    } else if (jdbcUrl.startsWith("jdbc:sqlite:")) {
        return DBType.SQLITE;
    } else if (jdbcUrl.startsWith("jdbc:h2:") || jdbcUrl.startsWith("jdbc:log4jdbc:h2:")) {
        return DBType.H2;
    } else {
        logger.warn("The jdbcUrl is " + jdbcUrl + ", Mybatis Plus Cannot Read Database type or The Database's Not Supported!");
        return DBType.OTHER;
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:37,代码来源:JdbcUtils.java


示例11: getDbType

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
public DBType getDbType() {
    return dbType;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:GlobalConfiguration.java


示例12: getIdentifierQuote

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
public String getIdentifierQuote() {
    if (null == identifierQuote) {
        return DBType.getQuote(dbType);
    }
    return identifierQuote;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:7,代码来源:GlobalConfiguration.java


示例13: getDbType

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
public static DBType getDbType(Configuration configuration) {
    return getGlobalConfig(configuration).getDbType();
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:4,代码来源:GlobalConfigUtils.java


示例14: mybatisSqlSessionFactoryBean

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**

     * 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定

     * 配置文件和mybatis-boot的配置文件同步

     * @return

     */
    @Bean
    public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean(DataSource dataSource) {
        MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();
        mybatisPlus.setDataSource(dataSource);
        mybatisPlus.setVfs(SpringBootVFS.class);
        if (StringUtils.hasText(this.properties.getConfigLocation())) {
            mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
        }
        mybatisPlus.setConfiguration(properties.getConfiguration());
        if (!ObjectUtils.isEmpty(this.interceptors)) {
            mybatisPlus.setPlugins(this.interceptors);
        }
        // MP 全局配置,更多内容进入类看注释

        GlobalConfiguration globalConfig = new GlobalConfiguration();
        globalConfig.setDbType(DBType.MYSQL.name());//数据库类型

        // ID 策略 AUTO->`0`("数据库ID自增") INPUT->`1`(用户输入ID") ID_WORKER->`2`("全局唯一ID") UUID->`3`("全局唯一ID")

        globalConfig.setIdType(3);
        //MP 属性下划线 转 驼峰 , 如果原生配置 mc.setMapUnderscoreToCamelCase(true) 开启,该配置可以无。

        globalConfig.setDbColumnUnderline(false);

        mybatisPlus.setGlobalConfig(globalConfig);
        MybatisConfiguration mc = new MybatisConfiguration();
        // 对于完全自定义的mapper需要加此项配置,才能实现下划线转驼峰

        mc.setMapUnderscoreToCamelCase(false);

        mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
        mybatisPlus.setConfiguration(mc);
        if (this.databaseIdProvider != null) {
            mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);
        }
        if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
            mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
        }
        if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
            mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
        }
        if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
            mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());
        }
        return mybatisPlus;
    }
 
开发者ID:timtu,项目名称:spring-boot-wechat,代码行数:56,代码来源:MybatisPlusConfig.java


示例15: mybatisSqlSessionFactoryBean

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定
 * 配置文件和mybatis-boot的配置文件同步
 * @return
 */
@Bean
@ConditionalOnMissingBean
public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean() {
    MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();
    mybatisPlus.setDataSource(dataSource);
    mybatisPlus.setVfs(SpringBootVFS.class);
    if (StringUtils.hasText(this.properties.getConfigLocation())) {
        mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
    }
    mybatisPlus.setConfiguration(properties.getConfiguration());
    if (!ObjectUtils.isEmpty(this.interceptors)) {
        mybatisPlus.setPlugins(this.interceptors);
    }
    // MP 全局配置,更多内容进入类看注释
    GlobalConfiguration globalConfig = new GlobalConfiguration();
    //驼峰下划线规则
    globalConfig.setDbColumnUnderline(true);
    globalConfig.setDbType(DBType.MYSQL.name());
    // ID 策略
    // AUTO->`0`("数据库ID自增")
    // INPUT->`1`(用户输入ID")
    // ID_WORKER->`2`("全局唯一ID")
    // UUID->`3`("全局唯一ID")
    globalConfig.setIdType(3);
    mybatisPlus.setGlobalConfig(globalConfig);
    MybatisConfiguration mc = new MybatisConfiguration();
    mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
    mybatisPlus.setConfiguration(mc);
    if (this.databaseIdProvider != null) {
        mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);
    }
    if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
        mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
    }
    if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
        mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
    }
    if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
        mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());
    }
    return mybatisPlus;
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:48,代码来源:MybatisPlusConfig.java


示例16: mybatisSqlSessionFactoryBean

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定
 * 配置文件和mybatis-boot的配置文件同步
 * @return
 */
@Bean
@ConditionalOnMissingBean
public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean() {
    MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();
    mybatisPlus.setDataSource(roundRobinDataSouceProxy());
    mybatisPlus.setVfs(SpringBootVFS.class);
    if (StringUtils.hasText(this.properties.getConfigLocation())) {
        mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
    }
    mybatisPlus.setConfiguration(properties.getConfiguration());
    if (!ObjectUtils.isEmpty(this.interceptors)) {
        mybatisPlus.setPlugins(this.interceptors);
    }
    // MP 全局配置,更多内容进入类看注释
    GlobalConfiguration globalConfig = new GlobalConfiguration();
    //驼峰下划线规则
    globalConfig.setDbColumnUnderline(true);
    globalConfig.setDbType(DBType.MYSQL.name());
    // ID 策略
    // AUTO->`0`("数据库ID自增")
    // INPUT->`1`(用户输入ID")
    // ID_WORKER->`2`("全局唯一ID")
    // UUID->`3`("全局唯一ID")
    globalConfig.setIdType(3);
    mybatisPlus.setGlobalConfig(globalConfig);
    MybatisConfiguration mc = new MybatisConfiguration();
    mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
    mybatisPlus.setConfiguration(mc);
    if (this.databaseIdProvider != null) {
        mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);
    }
    if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
        mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
    }
    if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
        mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
    }
    if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
        mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());
    }
    return mybatisPlus;
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:48,代码来源:MybatisPlusConfig.java


示例17: intercept

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
   * Physical Pagination Interceptor for all the queries with parameter {@link org.apache.ibatis.session.RowBounds}
   */
  @Override
  public Object intercept(Invocation invocation) throws Throwable {
      StatementHandler statementHandler = (StatementHandler) PluginUtils.realTarget(invocation.getTarget());
      MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
      this.sqlParser(metaObject);
      // 先判断是不是SELECT操作
      MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
      if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) {
          return invocation.proceed();
      }
      RowBounds rowBounds = (RowBounds) metaObject.getValue("delegate.rowBounds");
      /* 不需要分页的场合 */
      if (rowBounds == null || rowBounds == RowBounds.DEFAULT) {
          // 本地线程分页
          if (localPage) {
              // 采用ThreadLocal变量处理的分页
              rowBounds = PageHelper.getPagination();
              if (rowBounds == null) {
                  return invocation.proceed();
              }
          } else {
              // 无需分页
              return invocation.proceed();
          }
      }
      // 针对定义了rowBounds,做为mapper接口方法的参数
      BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
      String originalSql = boundSql.getSql();
      Connection connection = (Connection) invocation.getArgs()[0];
      DBType dbType = StringUtils.isNotEmpty(dialectType) ? DBType.getDBType(dialectType) : JdbcUtils.getDbType(connection.getMetaData().getURL());
      if (rowBounds instanceof Pagination) {
          Pagination page = (Pagination) rowBounds;
          boolean orderBy = true;
          if (page.isSearchCount()) {
              SqlInfo sqlInfo = SqlUtils.getCountOptimize(sqlParser, originalSql);
              orderBy = sqlInfo.isOrderBy();
              this.queryTotal(overflowCurrent, sqlInfo.getSql(), mappedStatement, boundSql, page, connection);
              if (page.getTotal() <= 0) {
                  return invocation.proceed();
              }
          }
          String buildSql = SqlUtils.concatOrderBy(originalSql, page, orderBy);
          originalSql = DialectFactory.buildPaginationSql(page, buildSql, dbType, dialectClazz);
      } else {
          // support physical Pagination for RowBounds
          originalSql = DialectFactory.buildPaginationSql(rowBounds, originalSql, dbType, dialectClazz);
      }

/*
       * <p> 禁用内存分页 </p>
       * <p> 内存分页会查询所有结果出来处理(这个很吓人的),如果结果变化频繁这个数据还会不准。</p>
 */
      metaObject.setValue("delegate.boundSql.sql", originalSql);
      metaObject.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
      metaObject.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);
      return invocation.proceed();
  }
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:61,代码来源:PaginationInterceptor.java


示例18: setDbType

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
public void setDbType(String dbType) {
    this.dbType = DBType.getDBType(dbType);
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:4,代码来源:GlobalConfiguration.java


示例19: convert

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 数据库字段转义
 * </p>
 *
 * @param globalConfig 全局配置
 * @param column       数据库字段
 * @return
 */
public static String convert(GlobalConfiguration globalConfig, String column) {
    if (globalConfig.getDbType() == DBType.POSTGRE) {
        // POSTGRE 直接转换
        return convertQuote(globalConfig, column);
    }
    return containsWord(column) ? convertQuote(globalConfig, column) : column;
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:17,代码来源:SqlReservedWords.java


示例20: buildPaginationSql

import com.baomidou.mybatisplus.enums.DBType; //导入依赖的package包/类
/**
 * <p>
 * 生成翻页执行 SQL
 * </p>
 *
 * @param page         翻页对象
 * @param buildSql     执行 SQL
 * @param dbType       数据库类型
 * @param dialectClazz 自定义方言实现类
 * @return
 * @throws Exception
 */
public static String buildPaginationSql(Pagination page, String buildSql, DBType dbType, String dialectClazz)
        throws Exception {
    // fix #172, 196
    return getiDialect(dbType, dialectClazz).buildPaginationSql(buildSql, page.getOffsetCurrent(), page.getSize());
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:18,代码来源:DialectFactory.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SingleSelectionModel类代码示例发布时间:2022-05-22
下一篇:
Java MarcXmlWriter类代码示例发布时间: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