java - Mybatis: Can Mybatis directly return a two-dimensional array (table)
高洛峰
高洛峰 2017-05-17 10:01:04
0
3
1262

Application scenario:Each mybaits result is mapped to an entity class. Sometimes when I am making front-end reports, I can directly get the desired report through SQL statements, but the results are all required. Map to an entity class. If individual fields in multiple reports are different, I need to create an entity class for each report (an unnecessary operation), and if a report needs to be modified Field, I also need to modify the corresponding entity class.

Question: Can I directly obtain a result similar to a two-dimensional array? I will directly use my sql query results.

PS: TriedresultType="java.util.List"limited the return result to List and returned the following error:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.UnsupportedOperationException
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
阿神

No, just go to bed

给我你的怀抱

Can only be basic types, Map or Object

phpcn_u1582
<resultMap id="FooResultMap" type="com.package.StringFoo">
    <result property="name" column="name"/>
    <collection property="foo" resultMap="FooMapORJavaType"/>
</resultMap>
<select id="findFoo" resultMap="FooResultMap"></select>

Hope this can help you
Reposted from
http://stackoverflow.com/ques...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template