[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6884) Attribute resultClass doesn't work with NamedNativeQuery

Tomasz Przybyła (JIRA) noreply at atlassian.com
Thu Dec 8 10:27:19 EST 2011


Attribute resultClass doesn't work with NamedNativeQuery
--------------------------------------------------------

                 Key: HHH-6884
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6884
             Project: Hibernate Core
          Issue Type: Bug
          Components: query-sql
    Affects Versions: 3.6.6
         Environment: Hibernate 3.6.6.Final over JPA 2.0
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
            Reporter: Tomasz Przybyła


Attribute resultClass is set to Long.class, but query returns a list of BigDecimal objects. Below you can see definition of NamedNativeQuery:
{code}
@NamedNativeQueries(
    @NamedNativeQuery(name = "getUserGroupsIds",
        query = "select id from identities_hierarchy connect by prior id = childid start with childid = ?",
        resultSetMapping = "groupIdMapping", resultClass = Long.class
    )
)
@SqlResultSetMapping(name = "groupIdMapping",
    columns = @ColumnResult(name = "id")
)
{code}

Following code executes this query:
{code}
List<Long> result = getEntityManager().createNamedQuery("getUserGroupsIds", Long.class)
    .setParameter(1, userId)
    .getResultList();

System.out.println("Returned object is of type: " + ((Iterator<?>) result.iterator()).next().getClass());
{code}

The id column in database is of type NUMBER(10, 0). There are no problems with CriteriaQueries and HQL. Any suggestion how to solve this problem will be greatly welcomed :]

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list