persistence@glassfish.java.net

SqlResultSetMapping entity and scalar types with toplink-essentials does not work for me

From: saturon <netbeans_at_vtxfree.ch>
Date: Tue, 8 Sep 2009 18:32:08 +0200

Hi there,

I cannot get SqlResultSetMapping with 2 scalar and 1 entity type to work
correctly. The scalar types somehow do not get mapped to the result, the
entity type does. Executing the query on a psql console returns always a
positive number for the counts, via JPA scalar types are null.

Setup:
Postgres 8.3
Glassfish 2.2 with toplink-essentials that came packed within
JPA

Entity:
@SqlResultSetMapping(name="myCount",
 
entities=_at_EntityResult(entityClass=Foo.class,fields=_at_FieldResult(name="i
d", column="id")),
 
columns={_at_ColumnResult(name="countAll"),_at_ColumnResult(name="countSome")}
)
@Entity
@Table(name = "my_foo")
public class Foo implements Serializable {
.

Query:
String sql = "select f.id,count(a.id) as countAll, count(b.id) as
countSome from my_foo f, ..";
List<Object[]> arr =
service.createNativeQuery(sql,"myCount").getResultList();

Expected Result: arr[0]: [ f: Foo, <number>, <number> ]

Actual Result: arr[0]: [ f:Foo, null, null ]


Thanks for pointers.


Ben
------------------------------------------------------------------------
---------