Mybatis usually uses javabean as the object of resultType, but sometimes map can also be used. And you can change the default uppercase key to lowercase.

http://blog.csdn.net/werewr342352321df/article/details/11892755

mybatis usually uses javabean as the resultType object, but sometimes you can also use map.
And you can change the default uppercase key to lowercase.
mybatis returns HashMap result type and mapping 
2012-04-20 21:39:05| Category: myBatis | Font size subscription

Xhtml code
<!-- Return HashMap result type --> 
    <!-- If you want to return JavaBean, just set resultType Set to the alias or fully qualified name of JavaBean --> 
    <!-- Some commonly used aliases are registered when the TypeAliasRegistry class is initialized. If you forget the alias, you can check it here --> 
    <select id="selectBlogRetHashMap" parameterType="int " resultType="map"> 
        SELECT id AS "id", title AS "title", content AS "content" FROM Blog WHERE id = #{id} 
    </select> 






    @SuppressWarnings("unchecked") 
    @Test 
    public void testSelectBlogRetHashMap() { 
        SqlSession session = sqlSessionFactory.openSession(); 
        HashMap<String,Object> blog = (HashMap<String,Object>) session.selectOne( 
                "cn.enjoylife.BlogMapper.selectBlogRetHashMap", 15); 
        session.close(); 
        System.out.println(blog.get("title")); 
    } 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326688725&siteId=291194637