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


Java Sql类代码示例

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


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

示例1: getSQL

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
public String getSQL(String id,Object params){
	
	try {
		SqlMapClientImpl sci = (SqlMapClientImpl)this.sqlMapClientTemplate.getSqlMapClient();  
    	MappedStatement ms = sci.getMappedStatement(id);  
    	          
    	Sql sql = ms.getSql();    
    	        
    	SessionScope sessionScope = new SessionScope();       
    	sessionScope.incrementRequestStackDepth();       
    	StatementScope statementScope = new StatementScope(sessionScope);       
    	ms.initRequest(statementScope);      
    	ms.getCacheKey(statementScope, params);  
    	
    	String sqlString = sql.getSql(statementScope, params);
    	Object[] sqlParam = sql.getParameterMap(statementScope, params).getParameterObjectValues(statementScope, params);  
    	
    	int sqlParamLen = sqlParam.length;
    	if (sqlParam != null && sqlParamLen > 0) {
    		for (int i=0; i < sqlParamLen; i++) {
    			if (sqlParam[i] instanceof Integer) {
    				sqlString = sqlString.replaceFirst("\\?", sqlParam[i].toString());
    			}
    			else if (sqlParam[i] instanceof String) {
    				sqlString = sqlString.replaceFirst("\\?", "'" + sqlParam[i].toString() + "'");
    			}
    		}
    	}
    	return sqlString;
	} catch (Exception ex) {
		LogConstant.error(ex.getMessage(), ex);
		LogConstant.error("获取SQL 出错, id: " + id);
	}
	
	return "[未能获取 SQL语句](id: " + id + ")";

}
 
开发者ID:shuqin,项目名称:ALLIN,代码行数:38,代码来源:SqlMapClientTemplateSupport.java

示例2: getSqlByStatementName

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
protected String getSqlByStatementName(String statementName, Object parameterObject) {
    SqlMapClientImpl sqlMapClientImpl = (SqlMapClientImpl) getSqlMapClient();
    Sql sql = sqlMapClientImpl.getMappedStatement(statementName).getSql();
    if (sql instanceof StaticSql) {
        return sql.getSql(null, parameterObject);
    } else {
        logger.info("dynamic sql can only return sql id.");
        return statementName;
    }
}
 
开发者ID:alibaba,项目名称:cobarclient,代码行数:11,代码来源:CobarSqlMapClientTemplate.java

示例3: getCacheKey

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
public CacheKey getCacheKey(StatementScope statementScope, Object parameterObject) {
  Sql sql = statementScope.getSql();
  ParameterMap pmap = sql.getParameterMap(statementScope, parameterObject);
  CacheKey cacheKey = pmap.getCacheKey(statementScope, parameterObject);
  cacheKey.update(id);

  // I am not sure how any clustered cache solution would ever have had any cache hits against
  // replicated objects. I could not make it happen
  // The baseCacheKey value which was being used in the update below is consistent across
  // JVMInstances on the same machine
  // but it's not consistent across machines, and therefore breaks clustered caching.

  // What would happen is the cache values were being replicated across machines but there
  // were never any cache hits for cached objects on
  // anything but the original machine an object was created on.

  // After reviewing this implementation I could not figure out why baseCacheKey is used for
  // this anyway as it's not needed, so I removed it.
  // The values used from the pmap.getCacheKey, plus id, plus the params below are unique and
  // the same accross machines, so now I get replicated
  // cache hits when I force failover in my cluster

  // I wish I could make a unit test for this, but I can't do it as the old implementaion
  // works on 1 machine, but fails across machines.
  // cacheKey.update(baseCacheKey);

  cacheKey.update(sql.getSql(statementScope, parameterObject)); // Fixes bug 953001
  return cacheKey;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:30,代码来源:MappedStatement.java

示例4: getSql

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
public Sql getSql() {
  return sql;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:4,代码来源:MappedStatement.java

示例5: setSql

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
public void setSql(Sql sql) {
  this.sql = sql;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:4,代码来源:MappedStatement.java

示例6: getSql

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
@Override
public Sql getSql() {
  return statement.getSql();
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:5,代码来源:CachingStatement.java

示例7: getSql

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
/**
 * Get the SQL for the request
 *
 * @return - the sql
 */
public Sql getSql() {
  return sql;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:9,代码来源:StatementScope.java

示例8: setSql

import com.ibatis.sqlmap.engine.mapping.sql.Sql; //导入依赖的package包/类
/**
 * Set the SQL for the request
 *
 * @param sql
 *          - the sql
 */
public void setSql(Sql sql) {
  this.sql = sql;
}
 
开发者ID:mybatis,项目名称:ibatis-2,代码行数:10,代码来源:StatementScope.java


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