openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhourui <zhou...@zoneland.net>
Subject how to use orderBy clause in tuple query?
Date Mon, 27 Apr 2015 13:31:50 GMT
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R
<openjpa-2.2.3-SNAPSHOT-r422266:1595313 nonfatal user error>
org.apache.openjpa.persistence.InvalidStateException:
使用过滤器“null”对候选类型“javax.persistence.criteria”执行了此查询,包括将多个查询的结果合并在内存中。您已选择对“”上的结果进行排序,但尚未在
setResult() 子句中选择此数据。请将此排序数据包含在 setResult() 中,以便
OpenJPA 可以抽取此数据以进行内存中排序。
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.getOrderingValue(ExpressionStoreQuery.java:837)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.OrderingMergedResultObjectProvider.getOrderingValue(OrderingMergedResultObjectProvider.java:62)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.lib.rop.MergedResultObjectProvider.next(MergedResultObjectProvider.java:172)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.QueryImpl$PackingResultObjectProvider.next(QueryImpl.java:2087)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:35)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1251)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.slice.DistributedQueryImpl.execute(DistributedQueryImpl.java:61)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
[15-4-27 21:18:26:952 CST] 000000d7 SystemErr     R 	at
com.ibm.ws.persistence.QueryImpl.getResultList(QueryImpl.java:118)


CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<WrapOutCompany> cq = cb.createQuery(WrapOutCompany.class);
Root<Company> root = cq.from(Company.class);
Predicate p = cb.equal(root.get(Company_.level), 1);
cq.multiselect(root.get(Company_.id), root.get(Company_.name),
root.get(Company_.unique), root.get(Company_.level),
root.get(Company_.superior));
cq.where(p);
cq.orderBy(cb.asc(root.get(Company_.name)));
return em.createQuery(cq).getResultList();

use tuple query, where with orderBy clause,it's throw exception,
but without orderBy clause,it's work fine.

how to use orderBy clause in tuple query?



--
View this message in context: http://openjpa.208410.n2.nabble.com/how-to-use-orderBy-clause-in-tuple-query-tp7588024.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message