當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。