how to [message #378602] |
Wed, 06 August 2008 04:18 |
Jasper Messages: 84 Registered: July 2009 |
Member |
|
|
Hi,
Can someone help me to get the @SqlResultSetMapping to work?
I can not find any examples for mapping the result from calling SQL
functions "min", "max" to the result object.
@NamedNativeQuery(name = "findIds", query = "select min(id) as minKey,
max(id) as maxKey from account",
resultSetMapping = "KeyRange")
@SqlResultSetMapping(name = "KeyRange",
entities = {
@EntityResult(entityClass=com.oracle.ngc.prototype.DataMigra tor.KeyRange.class,
fields = {
@FieldResult(name="min", column="minKey"),
@FieldResult(name="max", column="maxKey")
})})
With the above annotation, I got the following exception
[EPS Warning]: 2008.08.05
09:11:59.833--UnitOfWork(21697654)--java.lang.NullPointerExc eption
Exception in thread "Thread-2" java.lang.NullPointerException
at
org.eclipse.persistence.queries.EntityResult.getValueFromRec ord(EntityResult.java:147)
at
org.eclipse.persistence.queries.ResultSetMappingQuery.buildO bjectsFromRecords(ResultSetMappingQuery.java:158)
at
org.eclipse.persistence.queries.ResultSetMappingQuery.execut eDatabaseQuery(ResultSetMappingQuery.java:206)
at
org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:653)
at
org.eclipse.persistence.queries.DatabaseQuery.executeInUnitO fWork(DatabaseQuery.java:576)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2601)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1061)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1045)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1019)
at
org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1001)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeRea dQuery(EJBQueryImpl.java:399)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultL ist(EJBQueryImpl.java:517)
Thanks a lot.
Jasper
|
|
|
|
Re: how to construct the result mapping for calling aggreate function [message #379025 is a reply to message #379024] |
Wed, 06 August 2008 21:16 |
Eclipse User |
|
|
|
Originally posted by: jasper.lan.oracle.com
Thanks, Gordon.
Yes. It's an entity. But can I have it not as an entity if possible,
because it is just for a tempoary holder not really for persistence?
I also try the 'resultSetMapping' but also got a different EclipseLink
exception.
Surprisingly, I could not find anything like what I'm trying to achieve
after googling several days.
@NamedNativeQuery(name = "findIds", query = "select min(id) as minKey,
max(id) as maxKey from account",
resultSetMapping = "KeyRange")
@Entity
public class KeyRange {
String type;
long min;
long max;
|
|
|
Powered by
FUDForum. Page generated in 0.03132 seconds