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


Java RawSqlSource类代码示例

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


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

示例1: insert

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String insert(Class<?> entityType) {
	// 命令名称
	String statementId = buildStatementId(entityType, "insert");
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	// 创建命令
	String sql = new SqlBuilder(entityType).insert();
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.INSERT);
	// 判断是否需要自动生成主键
	EntityMetadata metadata = EntityMetadata.get(entityType);
	for (IdProperty idProperty : metadata.getIdProperties()) {
		KeyGenerator keyGenerator = idProperty.getKeyGenerator();
		if (keyGenerator == null) {
			continue;
		}
		String propertyName = idProperty.getName();
		String columnName = idProperty.getColumnName();
		statementBuilder.keyProperty(propertyName).keyColumn(columnName).keyGenerator(keyGenerator);
	}
	MappedStatement statement = statementBuilder.build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:27,代码来源:MappedStatementBuilder.java

示例2: createSqlSource

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
  // issue #3
  if (script.startsWith("<script>")) {
    XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
    return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
  } else {
    // issue #127
    script = PropertyParser.parse(script, configuration.getVariables());
    TextSqlNode textSqlNode = new TextSqlNode(script);
    if (textSqlNode.isDynamic()) {
      return new DynamicSqlSource(configuration, textSqlNode);
    } else {
      return new RawSqlSource(configuration, script, parameterType);
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:XMLLanguageDriver.java

示例3: createSqlSource

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
  // issue #3
  if (script.startsWith("<script>")) {
    XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
    return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
  } else {
    // issue #127
    script = PropertyParser.parse(script, configuration.getVariables());
    TextSqlNode textSqlNode = new TextSqlNode(script);
    //一种是动态,一种是原始
    if (textSqlNode.isDynamic()) {
      return new DynamicSqlSource(configuration, textSqlNode);
    } else {
      return new RawSqlSource(configuration, script, parameterType);
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:19,代码来源:XMLLanguageDriver.java

示例4: processMappedStatement

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
/**
 * 修改SqlSource
 *
 * @param ms
 * @throws Throwable
 */
public void processMappedStatement(MappedStatement ms) throws Throwable {
    SqlSource sqlSource = ms.getSqlSource();
    MetaObject msObject = SystemMetaObject.forObject(ms);
    SqlSource pageSqlSource;
    if (sqlSource instanceof StaticSqlSource) {
        pageSqlSource = new PageStaticSqlSource((StaticSqlSource) sqlSource);
    } else if (sqlSource instanceof RawSqlSource) {
        pageSqlSource = new PageRawSqlSource((RawSqlSource) sqlSource);
    } else if (sqlSource instanceof ProviderSqlSource) {
        pageSqlSource = new PageProviderSqlSource((ProviderSqlSource) sqlSource);
    } else if (sqlSource instanceof DynamicSqlSource) {
        pageSqlSource = new PageDynamicSqlSource((DynamicSqlSource) sqlSource);
    } else {
        throw new RuntimeException("无法处理该类型[" + sqlSource.getClass() + "]的SqlSource");
    }
    msObject.setValue("sqlSource", pageSqlSource);
    //由于count查询需要修改返回值,因此这里要创建一个Count查询的MS
    msCountMap.put(ms.getId(), MSUtils.newCountMappedStatement(ms));
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:26,代码来源:SqlUtil.java

示例5: paging

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String paging(Class<?> entityType, String condition, String orderBy, LockMode lockMode) {
	String statementId = this.buildStatementId(entityType, "[email protected]" + lockMode + "|" + condition + "|" + orderBy);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	ResultMap resultMap = resultMapBuilder.getDefault(entityType);
	String sql = new SqlBuilder(entityType).paging(condition, orderBy, lockMode);
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement statement = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.SELECT).resultMaps(Arrays.asList(resultMap)).build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:14,代码来源:MappedStatementBuilder.java

示例6: select

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String select(Class<?> entityType, String condition, String orderBy, LockMode lockMode) {
	String statementId = this.buildStatementId(entityType, "[email protected]" + lockMode + "|" + condition + "|" + orderBy);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	ResultMap resultMap = resultMapBuilder.getDefault(entityType);
	String sql = new SqlBuilder(entityType).select(condition, orderBy, lockMode);
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement statement = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.SELECT).resultMaps(Arrays.asList(resultMap)).build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:14,代码来源:MappedStatementBuilder.java

示例7: count

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String count(Class<?> entityType, String condition) {
	String statementId = this.buildStatementId(entityType, "[email protected]" + condition);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	ResultMap resultMap = resultMapBuilder.count(entityType);
	String sql = new SqlBuilder(entityType).count(condition);
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement statement = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.SELECT).resultMaps(Arrays.asList(resultMap)).build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:14,代码来源:MappedStatementBuilder.java

示例8: selectId

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String selectId(Class<?> entityType, String condition, String orderBy , Class<?> resultType) {
	String statementId = this.buildStatementId(entityType, "[email protected]" + resultType.getName() + "|" + condition + "|" + orderBy);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	ResultMap resultMap = resultMapBuilder.getId(entityType , resultType);
	String sql = new SqlBuilder(entityType).selectId(condition, orderBy);
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement statement = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.SELECT).resultMaps(Arrays.asList(resultMap)).build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:14,代码来源:MappedStatementBuilder.java

示例9: update

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String update(Class<?> entityType, String[] fields, String condition) {
	// 命令名称
	String statementId = buildStatementId(entityType, "[email protected]" + ArrayUtils.join(fields, ",") + ">" + condition);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	String sql = new SqlBuilder(entityType).update(fields, condition);
	// 创建命令
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.UPDATE);
	MappedStatement statement = statementBuilder.build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:16,代码来源:MappedStatementBuilder.java

示例10: delete

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public String delete(Class<?> entityType, String condition) {
	// 命令名称
	String statementId = buildStatementId(entityType, "[email protected]" + condition);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	String sql = new SqlBuilder(entityType).delete(condition);
	// 创建命令
	SqlSource sqlSource = new RawSqlSource(configuration, sql, null);
	MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.DELETE);
	MappedStatement statement = statementBuilder.build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:16,代码来源:MappedStatementBuilder.java

示例11: shouldUseRawSqlSourceForAnStaticStatement

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
@Test
public void shouldUseRawSqlSourceForAnStaticStatement() {
  test("getUser1", RawSqlSource.class);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:5,代码来源:RawSqlSourceTest.java

示例12: PageRawSqlSource

import org.apache.ibatis.scripting.defaults.RawSqlSource; //导入依赖的package包/类
public PageRawSqlSource(RawSqlSource sqlSource) {
    MetaObject metaObject = SystemMetaObject.forObject(sqlSource);
    this.sqlSource = new PageStaticSqlSource((StaticSqlSource) metaObject.getValue("sqlSource"));
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:5,代码来源:PageRawSqlSource.java


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