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


Java Configuration.getMappedStatement方法代码示例

本文整理汇总了Java中org.apache.ibatis.session.Configuration.getMappedStatement方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getMappedStatement方法的具体用法?Java Configuration.getMappedStatement怎么用?Java Configuration.getMappedStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.session.Configuration的用法示例。


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

示例1: testHierarchyHashSet

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
public void testHierarchyHashSet() throws Exception
{
    Configuration mybatisConfig = getConfiguration(HashSet.class);
    MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION);
    assertNotNull("Query missing for " + QUERY_ABSTRACTCOLLECTION + " using " + HashSet.class, stmt);
    try
    {
        mybatisConfig.getMappedStatement(QUERY_OBJECT);
        fail("Query not missing for " + QUERY_OBJECT + " using " + HashSet.class);
    }
    catch (IllegalArgumentException e)
    {
        // Expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:16,代码来源:HierarchicalSqlSessionFactoryBeanTest.java

示例2: testHierarchyTreeSet

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
public void testHierarchyTreeSet() throws Exception
{
    Configuration mybatisConfig = getConfiguration(TreeSet.class);
    MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_TREESET);
    assertNotNull("Query missing for " + QUERY_TREESET + " using " + TreeSet.class, stmt);
    try
    {
        mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION);
        fail("Query not missing for " + QUERY_ABSTRACTCOLLECTION + " using " + TreeSet.class);
    }
    catch (IllegalArgumentException e)
    {
        // Expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:16,代码来源:HierarchicalSqlSessionFactoryBeanTest.java

示例3: testHierarchyArrayList

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
public void testHierarchyArrayList() throws Exception
{
    Configuration mybatisConfig = getConfiguration(ArrayList.class);
    MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_ABSTRACTLIST);
    assertNotNull("Query missing for " + QUERY_ABSTRACTLIST + " using " + ArrayList.class, stmt);
    try
    {
        mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION);
        fail("Query not missing for " + QUERY_ABSTRACTCOLLECTION + " using " + ArrayList.class);
    }
    catch (IllegalArgumentException e)
    {
        // Expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:16,代码来源:HierarchicalSqlSessionFactoryBeanTest.java

示例4: testHierarchyAbstractCollection

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
public void testHierarchyAbstractCollection() throws Exception
{
    Configuration mybatisConfig = getConfiguration(AbstractCollection.class);
    MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION);
    assertNotNull("Query missing for " + QUERY_ABSTRACTCOLLECTION + " using " + AbstractCollection.class, stmt);
    try
    {
        mybatisConfig.getMappedStatement(QUERY_OBJECT);
        fail("Query not missing for " + QUERY_OBJECT + " using " + AbstractCollection.class);
    }
    catch (IllegalArgumentException e)
    {
        // Expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:16,代码来源:HierarchicalSqlSessionFactoryBeanTest.java

示例5: getNamespaceSql

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
/**
 * 通过命名空间方式获取sql
 * @param session
 * @param namespace
 * @param params
 * @return
 */
public static String getNamespaceSql(SqlSession session, String namespace, Object params) {
    Configuration configuration = session.getConfiguration();
    MappedStatement mappedStatement = configuration.getMappedStatement(namespace);
    TypeHandlerRegistry typeHandlerRegistry = mappedStatement.getConfiguration().getTypeHandlerRegistry();
    BoundSql boundSql = mappedStatement.getBoundSql(params);
    List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
    String sql = boundSql.getSql();
    if (parameterMappings != null) {
        for (int i = 0; i < parameterMappings.size(); i++) {
            ParameterMapping parameterMapping = parameterMappings.get(i);
            if (parameterMapping.getMode() != ParameterMode.OUT) {
                Object value;
                String propertyName = parameterMapping.getProperty();
                if (boundSql.hasAdditionalParameter(propertyName)) {
                    value = boundSql.getAdditionalParameter(propertyName);
                } else if (params == null) {
                    value = null;
                } else if (typeHandlerRegistry.hasTypeHandler(params.getClass())) {
                    value = params;
                } else {
                    MetaObject metaObject = configuration.newMetaObject(params);
                    value = metaObject.getValue(propertyName);
                }
                JdbcType jdbcType = parameterMapping.getJdbcType();
                if (value == null && jdbcType == null) jdbcType = configuration.getJdbcTypeForNull();
                sql = replaceParameter(sql, value, jdbcType, parameterMapping.getJavaType());
            }
        }
    }
    return sql;
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:39,代码来源:SqlHelper.java

示例6: addMappedStatement

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
public static MappedStatement addMappedStatement(Configuration cfg , MappedStatement ms) {
	String msId = ms.getId();
	StatementResultLock lock = StatementResultLock.getLock("s#".concat(msId));
	lock.lock();
	try {
		if (cfg.hasStatement(msId)) {
			return cfg.getMappedStatement(msId);
		}else{
			cfg.addMappedStatement(ms);	
			return ms;
		}
	} finally {
		lock.unlock();
	}
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:16,代码来源:StatementResultMapHelper.java

示例7: getCountMappedStatement

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
/**
 * 新建count查询的MappedStatement
 *
 * @param ms
 * @return
 */
public MappedStatement getCountMappedStatement(MappedStatement ms) {

    String newMsId = ms.getId() + PAGE_COUNT_SUFFIX;

    MappedStatement statement = null;
    Configuration configuration = ms.getConfiguration();

    try {
        statement = configuration.getMappedStatement(newMsId);
        if (statement != null) { return statement; }
    } catch (Exception e) {
    }

    synchronized (configuration) {

        if (configuration.hasStatement(newMsId)) { return configuration.getMappedStatement(newMsId); }

        MappedStatement.Builder builder = new MappedStatement.Builder(ms.getConfiguration(),
                newMsId, ms.getSqlSource(), ms.getSqlCommandType());
        builder.resource(ms.getResource());
        builder.fetchSize(ms.getFetchSize());
        builder.statementType(ms.getStatementType());
        builder.keyGenerator(ms.getKeyGenerator());
        if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) {
            StringBuilder keyProperties = new StringBuilder();
            for (String keyProperty : ms.getKeyProperties()) {
                keyProperties.append(keyProperty).append(",");
            }
            keyProperties.delete(keyProperties.length() - 1, keyProperties.length());
            builder.keyProperty(keyProperties.toString());
        }
        builder.timeout(ms.getTimeout());
        builder.parameterMap(ms.getParameterMap());
        //count查询返回值int
        List<ResultMap> resultMaps = new ArrayList<ResultMap>();
        String id = newMsId + "-Inline";
        ResultMap resultMap = new ResultMap.Builder(configuration, id, Long.class,
                new ArrayList<ResultMapping>(0)).build();
        resultMaps.add(resultMap);
        builder.resultMaps(resultMaps);

        builder.resultSetType(ms.getResultSetType());
        builder.cache(ms.getCache());
        builder.flushCacheRequired(ms.isFlushCacheRequired());
        builder.useCache(ms.isUseCache());

        statement = builder.build();
        configuration.addMappedStatement(statement);
        return statement;
    }

}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:59,代码来源:PaginationHandler.java

示例8: getQueryIdsMappedStatementForUpdateCache

import org.apache.ibatis.session.Configuration; //导入方法依赖的package包/类
private MappedStatement getQueryIdsMappedStatementForUpdateCache(MappedStatement mt,
                                                                 EntityInfo entityInfo) {
    String msId = mt.getId() + QUERY_IDS_SUFFIX;

    MappedStatement statement = null;
    Configuration configuration = mt.getConfiguration();
    try {
        statement = configuration.getMappedStatement(msId);
        if (statement != null) { return statement; }
    } catch (Exception e) {
    }

    synchronized (configuration) {
        if (configuration.hasStatement(msId)) { return configuration.getMappedStatement(msId); }

        String sql = entityInfo.getMapperSqls().get(mt.getId());

        if (StringUtils.isNotBlank(sql)) {
            if (!sql.toLowerCase().contains(entityInfo.getTableName().toLowerCase())) {
                return null;
            }
            sql = "select " + entityInfo.getIdColumn() + " from " + entityInfo.getTableName()
                    + " WHERE " + sql.split(WHERE_REGEX)[1];
            sql = String.format(SqlTemplate.SCRIPT_TEMAPLATE, sql);
        } else {
            sql = PARSE_SQL_ERROR_DEFAULT;
        }
        SqlSource sqlSource = configuration.getDefaultScriptingLanguageInstance()
                .createSqlSource(configuration, sql, Object.class);

        MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration,
                msId, sqlSource, SqlCommandType.SELECT);

        statementBuilder.resource(mt.getResource());
        statementBuilder.fetchSize(mt.getFetchSize());
        statementBuilder.statementType(mt.getStatementType());
        statementBuilder.parameterMap(mt.getParameterMap());
        statement = statementBuilder.build();

        List<ResultMap> resultMaps = new ArrayList<ResultMap>();

        String id = msId + "-Inline";
        ResultMap.Builder builder = new ResultMap.Builder(configuration, id,
                entityInfo.getIdType(), new ArrayList<ResultMapping>(), true);
        resultMaps.add(builder.build());
        MetaObject metaObject = SystemMetaObject.forObject(statement);
        metaObject.setValue("resultMaps", Collections.unmodifiableList(resultMaps));

        configuration.addMappedStatement(statement);

        return statement;
    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:54,代码来源:CacheHandler.java


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