persistence@glassfish.java.net

Re: Result of a native query with SqlResultSetMapping

From: Linda DeMichiel <Linda.Demichiel_at_Sun.COM>
Date: Tue, 07 Feb 2006 16:17:47 -0800

Hi Michael,

We agree with you, and are clarifying the spec to that effect.

regards,

Linda


Michael Bouschen wrote:

> Hi Linda, hi Mike,
>
> I was looking in one of the question raised in the glassfish forum:
> http://forums.java.net/jive/thread.jspa?threadID=2667&tstart=0
>
> The question is about the result returned by Query.getResultList for a
> native query using a SqlResultSetMapping. I understand that the query
> returns a list of arrays if the SqlResultSetMapping specifies multiple
> entity types. But does it still use an array as the list element in case
> there is only a single entity type? Or does the query return a list of
> entities? The user posting the forum question is expecting the latter
> which sounds reasonable to me.
>
> Here is a simple example:
> @SqlResultSetMapping(name="simpleCustomerMapping",
> entities={_at_EntityResult(entityClass=ejbql.models.Customer.class)})
> Query q = em.createNativeQuery(
> "SELECT ID, VERSION, CITY, NAME FROM CUSTOMER_TABLE WHERE ID=1",
> "simpleCustomerMapping");
> Does query.getResultList() return List<Customer[]> or List<Customer>?
>
> What do you think?
>
> Regards Michael