Community
Participate
Working Groups
Build Identifier: 2.3.2 When you use nativeQuery with type cast, then the resultset's first element is ok, but all the others are filled with nulls. public List<UserStatusType> getEntities() { List<EntityName> res = new ArrayList<EntityName>(); res = em.createNativeQuery("select * from tbl", EntityName.class) .getResultList(); return res; } If you annotating the entity with SqlResultSetMapping and sets all the fields that you need, then it's working fine.: @SqlResultSetMapping( name="statusResult", entities=@EntityResult( entityClass=EntityName.class, fields={ @FieldResult(name="id", column="ID"), @FieldResult(name="statusName", column="StatusName") } ) ) public List<UserStatusType> getEntities() { List<EntityName> res = new ArrayList<EntityName>(); res = em.createNativeQuery("select * from tbl", "statusResult") .getResultList(); return res; } With version 2.2.1 it's also working fine with typecast and resultset mapping too. Reproducible: Always Steps to Reproduce: 1. create native query with a simple select 2. run it 3. create native query with a complete SqlResultSetMapping 4. run it
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
This does not have a test case, and our tests using Native queries to return entities are working, so I will have to mark this as works for me unless an example that reproduces is provided. Looking at the example resultset though, it suggests that "ID" is working while "StatusName" and the other fields that are not might have a mixed case. As EclipseLink is case sensitive (or more that Java hashcodes are case sensitive) how the fields are defined must match how the fields are returned from the database in the resultset. This is database dependent, but EclipseLink can be made to upper case everything to get around this using the "eclipselink.jpa.uppercase-column-names" persistence property.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink