本文整理汇总了Java中org.apache.ibatis.scripting.LanguageDriver.createSqlSource方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageDriver.createSqlSource方法的具体用法?Java LanguageDriver.createSqlSource怎么用?Java LanguageDriver.createSqlSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.scripting.LanguageDriver
的用法示例。
在下文中一共展示了LanguageDriver.createSqlSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: genKeyGenerator
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* <p>
* 自定义 KEY 生成器
* </p>
*/
public static KeyGenerator genKeyGenerator(TableInfo tableInfo, MapperBuilderAssistant builderAssistant,
String baseStatementId, LanguageDriver languageDriver) {
Incrementer incrementer = GlobalConfigUtils.getIncrementer(builderAssistant.getConfiguration());
if (null == incrementer) {
throw new MybatisPlusException("Error: not configure Incrementer implementation class.");
}
String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
Class<?> resultTypeClass = tableInfo.getKeySequence().idClazz();
StatementType statementType = StatementType.PREPARED;
String keyProperty = tableInfo.getKeyProperty();
String keyColumn = tableInfo.getKeyColumn();
SqlSource sqlSource = languageDriver.createSqlSource(builderAssistant.getConfiguration(),
incrementer.getSequenceQuery(tableInfo.getKeySequence().value()), null);
builderAssistant.addMappedStatement(id, sqlSource, statementType, SqlCommandType.SELECT, null, null, null,
null, null, resultTypeClass, null, false, false, false,
new NoKeyGenerator(), keyProperty, keyColumn, null, languageDriver, null);
id = builderAssistant.applyCurrentNamespace(id, false);
MappedStatement keyStatement = builderAssistant.getConfiguration().getMappedStatement(id, false);
SelectKeyGenerator keyGenerator = new SelectKeyGenerator(keyStatement, true);
builderAssistant.getConfiguration().addKeyGenerator(id, keyGenerator);
return keyGenerator;
}
示例2: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver,
EntityInfo entity) {
String[] names = GeneralSqlGenerator.methodDefines.updateName().split(",");
for (String name : names) {
String msId = entity.getMapperClass().getName() + "." + name;
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
String sql = buildUpdateSql(entityMapper, name.endsWith("Selective"));
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql,
entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration,
msId, sqlSource, SqlCommandType.UPDATE);
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
}
示例3: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.deleteName();
// 从参数对象里提取注解信息
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
// 生成sql
String sql = buildDeleteSql(entityMapper);
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.DELETE);
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
示例4: genKeyGenerator
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* <p>
* 自定义 KEY 生成器
* </p>
*/
public static KeyGenerator genKeyGenerator(TableInfo tableInfo, MapperBuilderAssistant builderAssistant,
String baseStatementId, LanguageDriver languageDriver) {
IKeyGenerator keyGenerator = GlobalConfigUtils.getKeyGenerator(builderAssistant.getConfiguration());
if (null == keyGenerator) {
throw new IllegalArgumentException("not configure IKeyGenerator implementation class.");
}
String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
Class<?> resultTypeClass = tableInfo.getKeySequence().clazz();
StatementType statementType = StatementType.PREPARED;
String keyProperty = tableInfo.getKeyProperty();
String keyColumn = tableInfo.getKeyColumn();
SqlSource sqlSource = languageDriver.createSqlSource(builderAssistant.getConfiguration(),
keyGenerator.executeSql(tableInfo.getKeySequence().value()), null);
builderAssistant.addMappedStatement(id, sqlSource, statementType, SqlCommandType.SELECT, null, null, null,
null, null, resultTypeClass, null, false, false, false,
new NoKeyGenerator(), keyProperty, keyColumn, null, languageDriver, null);
id = builderAssistant.applyCurrentNamespace(id, false);
MappedStatement keyStatement = builderAssistant.getConfiguration().getMappedStatement(id, false);
SelectKeyGenerator selectKeyGenerator = new SelectKeyGenerator(keyStatement, true);
builderAssistant.getConfiguration().addKeyGenerator(id, selectKeyGenerator);
return selectKeyGenerator;
}
示例5: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration,LanguageDriver languageDriver, EntityInfo entity) {
String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.deleteName();
// 从参数对象里提取注解信息
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
// 生成sql
String sql = buildDeleteSql(entityMapper);
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource,SqlCommandType.DELETE);
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
示例6: buildSqlSourceFromStrings
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
private SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
final StringBuilder sql = new StringBuilder();
for (String fragment : strings) {
sql.append(fragment);
sql.append(" ");
}
return languageDriver.createSqlSource(configuration, sql.toString().trim(), parameterTypeClass);
}
示例7: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String[] names = GeneralSqlGenerator.methodDefines.insertName().split(",");
for (String name : names) {
String msId = entity.getMapperClass().getName() + "." + name;
// 从参数对象里提取注解信息
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
// 生成sql
String sql = buildInsertSql(entityMapper, name.endsWith("Selective"));
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.INSERT);
KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
statementBuilder.keyGenerator(keyGenerator)//
.keyProperty(entityMapper.getIdColumn().getProperty())//
.keyColumn(entityMapper.getIdColumn().getColumn());
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
}
示例8: buildSqlSourceFromStrings
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
private SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
final StringBuilder sql = new StringBuilder();
for (String fragment : strings) {
sql.append(fragment);
sql.append(" ");
}
return languageDriver.createSqlSource(configuration, sql.toString().trim(), parameterTypeClass);
}
示例9: parseSelectKeyNode
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
private void parseSelectKeyNode(String id, XNode nodeToHandle, Class<?> parameterTypeClass, LanguageDriver langDriver, String databaseId) {
String resultType = nodeToHandle.getStringAttribute("resultType");
Class<?> resultTypeClass = resolveClass(resultType);
StatementType statementType = StatementType.valueOf(nodeToHandle.getStringAttribute("statementType", StatementType.PREPARED.toString()));
String keyProperty = nodeToHandle.getStringAttribute("keyProperty");
String keyColumn = nodeToHandle.getStringAttribute("keyColumn");
boolean executeBefore = "BEFORE".equals(nodeToHandle.getStringAttribute("order", "AFTER"));
//defaults
boolean useCache = false;
boolean resultOrdered = false;
KeyGenerator keyGenerator = new NoKeyGenerator();
Integer fetchSize = null;
Integer timeout = null;
boolean flushCache = false;
String parameterMap = null;
String resultMap = null;
ResultSetType resultSetTypeEnum = null;
SqlSource sqlSource = langDriver.createSqlSource(configuration, nodeToHandle, parameterTypeClass);
SqlCommandType sqlCommandType = SqlCommandType.SELECT;
builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
resultSetTypeEnum, flushCache, useCache, resultOrdered,
keyGenerator, keyProperty, keyColumn, databaseId, langDriver, null);
id = builderAssistant.applyCurrentNamespace(id, false);
MappedStatement keyStatement = configuration.getMappedStatement(id, false);
configuration.addKeyGenerator(id, new SelectKeyGenerator(keyStatement, executeBefore));
}
示例10: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver,EntityInfo entity) {
String[] names = GeneralSqlGenerator.methodDefines.insertName().split(",");
for (String name : names) {
String msId = entity.getMapperClass().getName() + "." + name;
// 从参数对象里提取注解信息
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
// 生成sql
String sql = buildInsertSql(entityMapper,name.endsWith("Selective"));
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource,SqlCommandType.INSERT);
KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
statementBuilder.keyGenerator(keyGenerator)//
.keyProperty(entityMapper.getIdColumn().getProperty())//
.keyColumn(entityMapper.getIdColumn().getColumn());
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
}
示例11: buildSqlSourceFromStrings
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
private SqlSource buildSqlSourceFromStrings(String[] strings, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
final StringBuilder sql = new StringBuilder();
for (String fragment : strings) {
sql.append(fragment);
sql.append(" ");
}
return languageDriver.createSqlSource(configuration, sql.toString(), parameterTypeClass);
}
示例12: parseSelectKeyNode
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
private void parseSelectKeyNode(String id, XNode nodeToHandle, Class<?> parameterTypeClass, LanguageDriver langDriver, String databaseId) {
String resultType = nodeToHandle.getStringAttribute("resultType");
Class<?> resultTypeClass = resolveClass(resultType);
StatementType statementType = StatementType.valueOf(nodeToHandle.getStringAttribute("statementType", StatementType.PREPARED.toString()));
String keyProperty = nodeToHandle.getStringAttribute("keyProperty");
String keyColumn = nodeToHandle.getStringAttribute("keyColumn");
boolean executeBefore = "BEFORE".equals(nodeToHandle.getStringAttribute("order", "AFTER"));
//defaults
boolean useCache = false;
boolean resultOrdered = false;
KeyGenerator keyGenerator = NoKeyGenerator.INSTANCE;
Integer fetchSize = null;
Integer timeout = null;
boolean flushCache = false;
String parameterMap = null;
String resultMap = null;
ResultSetType resultSetTypeEnum = null;
SqlSource sqlSource = langDriver.createSqlSource(configuration, nodeToHandle, parameterTypeClass);
SqlCommandType sqlCommandType = SqlCommandType.SELECT;
builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
resultSetTypeEnum, flushCache, useCache, resultOrdered,
keyGenerator, keyProperty, keyColumn, databaseId, langDriver, null);
id = builderAssistant.applyCurrentNamespace(id, false);
MappedStatement keyStatement = configuration.getMappedStatement(id, false);
configuration.addKeyGenerator(id, new SelectKeyGenerator(keyStatement, executeBefore));
}
示例13: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.selectName();
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
String sql = buildGetByIdSql(entityMapper);
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.SELECT);
// 将返回值修改为实体类型
MappedStatement statement = statementBuilder.build();
setResultType(configuration, statement, entity.getEntityClass());
configuration.addMappedStatement(statement);
}
示例14: parseStatementNode
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
public void parseStatementNode() {
String id = context.getStringAttribute("id");
String databaseId = context.getStringAttribute("databaseId");
if (!databaseIdMatchesCurrent(id, databaseId, this.requiredDatabaseId)) {
return;
}
Integer fetchSize = context.getIntAttribute("fetchSize");
Integer timeout = context.getIntAttribute("timeout");
String parameterMap = context.getStringAttribute("parameterMap");
String parameterType = context.getStringAttribute("parameterType");
Class<?> parameterTypeClass = resolveClass(parameterType);
String resultMap = context.getStringAttribute("resultMap");
String resultType = context.getStringAttribute("resultType");
String lang = context.getStringAttribute("lang");
LanguageDriver langDriver = getLanguageDriver(lang);
Class<?> resultTypeClass = resolveClass(resultType);
String resultSetType = context.getStringAttribute("resultSetType");
StatementType statementType = StatementType.valueOf(context.getStringAttribute("statementType", StatementType.PREPARED.toString()));
ResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);
String nodeName = context.getNode().getNodeName();
SqlCommandType sqlCommandType = SqlCommandType.valueOf(nodeName.toUpperCase(Locale.ENGLISH));
boolean isSelect = sqlCommandType == SqlCommandType.SELECT;
boolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);
boolean useCache = context.getBooleanAttribute("useCache", isSelect);
boolean resultOrdered = context.getBooleanAttribute("resultOrdered", false);
// Include Fragments before parsing
XMLIncludeTransformer includeParser = new XMLIncludeTransformer(configuration, builderAssistant);
includeParser.applyIncludes(context.getNode());
// Parse selectKey after includes and remove them.
processSelectKeyNodes(id, parameterTypeClass, langDriver);
// Parse the SQL (pre: <selectKey> and <include> were parsed and removed)
SqlSource sqlSource = langDriver.createSqlSource(configuration, context, parameterTypeClass);
String resultSets = context.getStringAttribute("resultSets");
String keyProperty = context.getStringAttribute("keyProperty");
String keyColumn = context.getStringAttribute("keyColumn");
KeyGenerator keyGenerator;
String keyStatementId = id + SelectKeyGenerator.SELECT_KEY_SUFFIX;
keyStatementId = builderAssistant.applyCurrentNamespace(keyStatementId, true);
if (configuration.hasKeyGenerator(keyStatementId)) {
keyGenerator = configuration.getKeyGenerator(keyStatementId);
} else {
keyGenerator = context.getBooleanAttribute("useGeneratedKeys",
configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType))
? new Jdbc3KeyGenerator() : new NoKeyGenerator();
}
builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
resultSetTypeEnum, flushCache, useCache, resultOrdered,
keyGenerator, keyProperty, keyColumn, databaseId, langDriver, resultSets);
}
示例15: build
import org.apache.ibatis.scripting.LanguageDriver; //导入方法依赖的package包/类
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration,LanguageDriver languageDriver, EntityInfo entity) {
String[] names = GeneralSqlGenerator.methodDefines.updateName().split(",");
for (String name : names) {
String msId = entity.getMapperClass().getName() + "." + name;
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
String sql = buildUpdateSql(entityMapper,name.endsWith("Selective"));
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource,SqlCommandType.UPDATE);
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
}