Home  >  Q&A  >  body text

java - Mybatis: Can Mybatis directly return a two-dimensional array (table)

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
高洛峰高洛峰2734 days ago1243

reply all(3)I'll reply

  • 阿神

    阿神2017-05-17 10:03:04

    No, just go to bed

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-17 10:03:04

    Can only be basic types, Map or Object

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-17 10:03:04

    <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...

    reply
    0
  • Cancelreply