当前位置: 首页>>代码示例>>Java>>正文


Java Log类代码示例

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


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

示例1: LoadPair

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private LoadPair(final String property, MetaObject metaResultObject, ResultLoader resultLoader) {
  this.property = property;
  this.metaResultObject = metaResultObject;
  this.resultLoader = resultLoader;

  /* Save required information only if original object can be serialized. */
  if (metaResultObject != null && metaResultObject.getOriginalObject() instanceof Serializable) {
    final Object mappedStatementParameter = resultLoader.parameterObject;

    /* @todo May the parameter be null? */
    if (mappedStatementParameter instanceof Serializable) {
      this.mappedStatement = resultLoader.mappedStatement.getId();
      this.mappedParameter = (Serializable) mappedStatementParameter;

      this.configurationFactory = resultLoader.configuration.getConfigurationFactory();
    } else {
      Log log = this.getLogger();
      if (log.isDebugEnabled()) {
        log.debug("Property [" + this.property + "] of ["
                + metaResultObject.getOriginalObject().getClass() + "] cannot be loaded "
                + "after deserialization. Make sure it's loaded before serializing "
                + "forenamed object.");
      }
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:27,代码来源:ResultLoaderMap.java

示例2: prepareStatement

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException {
  Statement stmt;
  //得到绑定的SQL语句
  BoundSql boundSql = handler.getBoundSql();
  String sql = boundSql.getSql();
  //如果缓存中已经有了,直接得到Statement
  if (hasStatementFor(sql)) {
    stmt = getStatement(sql);
  } else {
    //如果缓存没有找到,则和SimpleExecutor处理完全一样,然后加入缓存
    Connection connection = getConnection(statementLog);
    stmt = handler.prepare(connection);
    putStatement(sql, stmt);
  }
  handler.parameterize(stmt);
  return stmt;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:18,代码来源:ReuseExecutor.java

示例3: bindingLog

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private void bindingLog(Invocation invocation) throws SQLException {

        Object[] args = invocation.getArgs();
        MappedStatement ms = (MappedStatement) args[0];
        Object parameterObject = args[1];
        StatementType statementType = ms.getStatementType();
        if (StatementType.PREPARED == statementType || StatementType.CALLABLE == statementType) {
            Log statementLog = ms.getStatementLog();
            if (isDebugEnable(statementLog)) {
                BoundSql boundSql = ms.getBoundSql(parameterObject);

                String sql = boundSql.getSql();
                List<String> parameterList = getParameters(ms, parameterObject, boundSql);
                debug(statementLog, "==> BindingLog: " + bindLogFormatter.format(sql, parameterList));
            }
        }
    }
 
开发者ID:naver,项目名称:pinpoint,代码行数:18,代码来源:BindingLogPlugin32.java

示例4: settingsElement

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
    configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
    configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
    configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
    configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
    configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
    configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), false));
    configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
    configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
    configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
    configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
    configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
    configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
    configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
    configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
    configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
    configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
    configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
    configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
    configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
    configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
    configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
    configuration.setReturnInstanceForEmptyRow(booleanValueOf(props.getProperty("returnInstanceForEmptyRow"), false));
    configuration.setLogPrefix(props.getProperty("logPrefix"));
    @SuppressWarnings("unchecked")
    Class<? extends Log> logImpl = (Class<? extends Log>) resolveClass(props.getProperty("logImpl"));
    configuration.setLogImpl(logImpl);
    configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:30,代码来源:MybatisXMLConfigBuilder.java

示例5: BaseJdbcLogger

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
public BaseJdbcLogger(Log log, int queryStack) {
  this.statementLog = log;
  if (queryStack == 0) {
    this.queryStack = 1;
  } else {
    this.queryStack = queryStack;
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:BaseJdbcLogger.java

示例6: settingsElement

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private void settingsElement(Properties props) throws Exception {
  configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL")));
  configuration.setAutoMappingUnknownColumnBehavior(AutoMappingUnknownColumnBehavior.valueOf(props.getProperty("autoMappingUnknownColumnBehavior", "NONE")));
  configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
  configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory")));
  configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
  configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
  configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
  configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
  configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false));
  configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE")));
  configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null));
  configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null));
  configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false));
  configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false));
  configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION")));
  configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER")));
  configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString"));
  configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true));
  configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage")));
  configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false));
  configuration.setUseActualParamName(booleanValueOf(props.getProperty("useActualParamName"), true));
  configuration.setLogPrefix(props.getProperty("logPrefix"));
  @SuppressWarnings("unchecked")
  Class<? extends Log> logImpl = (Class<? extends Log>)resolveClass(props.getProperty("logImpl"));
  configuration.setLogImpl(logImpl);
  configuration.setConfigurationFactory(resolveClass(props.getProperty("configurationFactory")));
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:29,代码来源:XMLConfigBuilder.java

示例7: getConnection

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
protected Connection getConnection(Log statementLog) throws SQLException {
  Connection connection = transaction.getConnection();
  if (statementLog.isDebugEnabled()) {
    return ConnectionLogger.newInstance(connection, statementLog, queryStack);
  } else {
    return connection;
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:BaseExecutor.java

示例8: prepareStatement

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException {
  Statement stmt;
  BoundSql boundSql = handler.getBoundSql();
  String sql = boundSql.getSql();
  if (hasStatementFor(sql)) {
    stmt = getStatement(sql);
    applyTransactionTimeout(stmt);
  } else {
    Connection connection = getConnection(statementLog);
    stmt = handler.prepare(connection, transaction.getTimeout());
    putStatement(sql, stmt);
  }
  handler.parameterize(stmt);
  return stmt;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:16,代码来源:ReuseExecutor.java

示例9: prepareStatement

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException {
  Statement stmt;
  Connection connection = getConnection(statementLog);
  stmt = handler.prepare(connection, transaction.getTimeout());
  handler.parameterize(stmt);
  return stmt;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:SimpleExecutor.java

示例10: setLogImpl

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setLogImpl(Class<?> logImpl) {
  if (logImpl != null) {
    this.logImpl = (Class<? extends Log>) logImpl;
    LogFactory.useCustomLogging(this.logImpl);
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:8,代码来源:Configuration.java

示例11: getConnection

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
protected Connection getConnection(Log statementLog) throws SQLException {
  // 源码解析: 从事务获取数据库连接
  Connection connection = transaction.getConnection();
  if (statementLog.isDebugEnabled()) {
    // 源码解析: debug模式下, 返回connection的包装对象
    return ConnectionLogger.newInstance(connection, statementLog, queryStack);
  } else {
    return connection;
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:11,代码来源:BaseExecutor.java

示例12: prepareStatement

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException {
  Statement stmt;
  // 源码解析: 获取数据库连接
  Connection connection = getConnection(statementLog);
  // 源码解析: 创建Statement
  stmt = handler.prepare(connection, transaction.getTimeout());
  handler.parameterize(stmt);
  return stmt;
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:10,代码来源:SimpleExecutor.java

示例13: setLogImpl

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setLogImpl(Class<?> logImpl) {
	if (logImpl != null) {
		this.logImpl = (Class<? extends Log>) logImpl;
		LogFactory.useCustomLogging(this.logImpl);
	}
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:8,代码来源:Configuration.java

示例14: getCount

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
/**
     * 查询总纪录数
     * @param sql             SQL语句
     * @param connection      数据库连接
     * @param mappedStatement mapped
     * @param parameterObject 参数
     * @param boundSql        boundSql
     * @return 总记录数
     * @throws SQLException sql查询错误
     */
    public static int getCount(final String sql, final Connection connection,
    							final MappedStatement mappedStatement, final Object parameterObject,
    							final BoundSql boundSql, Log log) throws SQLException {
        final String countSql = "select count(1) from (" + sql + ") tmp_count";
//        final String countSql = "select count(1) " + removeSelect(removeOrders(sql));
        Connection conn = connection;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
        	if (log.isDebugEnabled()) {
                log.debug("COUNT SQL: " + StringUtils.replaceEach(countSql, new String[]{"\n", "\t"}, new String[]{" ", " "}));
            }
        	if (conn == null){
        		conn = mappedStatement.getConfiguration().getEnvironment().getDataSource().getConnection();
            }
        	ps = conn.prepareStatement(countSql);
            BoundSql countBS = new BoundSql(mappedStatement.getConfiguration(), countSql,
                    boundSql.getParameterMappings(), parameterObject);
            SQLHelper.setParameters(ps, mappedStatement, countBS, parameterObject);
            rs = ps.executeQuery();
            int count = 0;
            if (rs.next()) {
                count = rs.getInt(1);
            }
            return count;
        } finally {
            if (rs != null) {
                rs.close();
            }
            if (ps != null) {
            	ps.close();
            }
            if (conn != null) {
            	conn.close();
            }
        }
    }
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:48,代码来源:SQLHelper.java

示例15: getConnection

import org.apache.ibatis.logging.Log; //导入依赖的package包/类
protected Connection getConnection(Log statementLog) throws SQLException {
  Connection connection = transaction.getConnection();
  if (statementLog.isDebugEnabled()) {
    //如果需要打印Connection的日志,返回一个ConnectionLogger(代理模式, AOP思想)
    return ConnectionLogger.newInstance(connection, statementLog, queryStack);
  } else {
    return connection;
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:10,代码来源:BaseExecutor.java


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