本文整理汇总了Java中org.apache.ibatis.logging.Log.isDebugEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Log.isDebugEnabled方法的具体用法?Java Log.isDebugEnabled怎么用?Java Log.isDebugEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.logging.Log
的用法示例。
在下文中一共展示了Log.isDebugEnabled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
}
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: 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();
}
}
}
示例5: 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;
}
}
示例6: debug
import org.apache.ibatis.logging.Log; //导入方法依赖的package包/类
public void debug(Log statementLogger, String msg) {
if (statementLogger.isDebugEnabled()) {
statementLogger.debug(msg);
} else {
pLogger.debug(msg);
}
}
示例7: 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 {
String dbName = Global.getConfig("jdbc.type");
final String countSql;
if ("oracle".equals(dbName)) {
countSql = "select count(1) from (" + sql + ") tmp_count";
} else {
countSql = "select count(1) from (" + removeOrders(sql) + ") tmp_count";
// 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);
// 解决MyBatis 分页foreach 参数失效 start
if (Reflections.getFieldValue(boundSql, "metaParameters") != null) {
MetaObject mo = (MetaObject) Reflections.getFieldValue(boundSql, "metaParameters");
Reflections.setFieldValue(countBS, "metaParameters", mo);
}
// 解决MyBatis 分页foreach 参数失效 end
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();
}
}
}
示例8: isDebugEnable
import org.apache.ibatis.logging.Log; //导入方法依赖的package包/类
public boolean isDebugEnable(Log statementLogger) {
return statementLogger.isDebugEnabled() || pLogger.isDebugEnabled();
}