最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to get a query result in List<Object[]> type in orm.xml with JPA? - Stack Overflow

programmeradmin0浏览0评论

I'm trying to get a query result in List<Object[]> type by a named native query, which is defined at the orm.xml.

When I run the code, it gives me an error as following:

Cannot create TypedQuery for query with more than one return using requested result type

Here's the orm.xml

<named-native-query name="UserInfo.findByCompCode" result-set-mapping="tmp">
    <query>
        SELECT
            A.USER_ID
            , B.USER_AREA_CODE
        FROM
             USER A
             , USER_DETAIL B
        WHERE
             A.USER_ID = B.USER_ID
             AND A.COMP_CODE = '01'
    <query>
</named-native-query>
<sql-result-set-mapping name="tmp">
     <column-result name="USER_ID" />
     <column-result name="USER_AREA_CODE" />
</sql-result-set-mapping>

The return type of the repository is List<Object[]>.

How can I get the query result in List<Object[]> type?

Thanks in advance

发布评论

评论列表(0)

  1. 暂无评论