Query q = em.createNamedQuery("selectCategoryYear");
        List<Object> objectList = q.getResultList();
        for (Object o : objectList) {
            System.out.println(o.getClass().getSimpleName());
        }
it says it is returning Object[]

On 08/03/2018 13:46, Craig Taylor wrote:
Try using longs instead of integer.  If you grab the result set without
conversion you should be able to iterate through the list to see what is
being returned.

On Mar 8, 2018 07:38, "Matthew Broadhead" <matthew.broadh...@nbmlaw.co.uk>
wrote:

hi i am trying to do a NamedNativeQuery with a SqlResultSetMapping and i
get javax.el.ELException: java.lang.ClassCastException: [Ljava.lang.Object;
cannot be cast to uk.me.kissy.file.entities.categoryYear.CategoryYearResult.
is this type of operation not supported?
my orm.xml is
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.1"
     xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd";>
     <entity class="uk.me.kissy.file.entities.jpa.File" name="File">
         <named-native-query name="selectCategoryYear"
             result-set-mapping="CategoryYearMapping">
             <query><![CDATA[select year(completiondate) as year,
categoryid, count(id) as count from conveyancing.file where completiondate
is not null and categoryid is not null group by year, categoryid order by
year;]]></query>
         </named-native-query>
         <sql-result-set-mapping name="CategoryYearMapping">
             <constructor-result
target-class="uk.me.kissy.file.entities.categoryYear.CategoryYearResult">
                 <column name="year" class="java.lang.Integer" />
                 <column name="categoryid" class="java.lang.Integer" />
                 <column name="count" class="java.lang.Integer" />
             </constructor-result>
         </sql-result-set-mapping>
     </entity>
</entity-mappings>


Reply via email to