SqlResultSetMapping entity and scalar types with toplink-essentials does not work for me
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=@EntityResult(entityClass=Foo.class,fields=@FieldResult(name="id", column="id")),
columns={@ColumnResult(name="countAll"),@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
---------------------------------------------------------------------------------