Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPQL:EclipseLink ORDER BY on boolean fields

657525Mar 11 2009 — edited Mar 12 2009
I have an entity Config which has a boolean field enable.

I want to sort all configs by enable field.

jpql = "SELECT c FROM Config c ORDER BY c.enable"; // enable is a boolean in entity.

When I execute above JPQL i am getting below exception

How can i achieve this using JPQL ? or any EclipseLink specific way ?

Exception in thread "main" java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:735)
at oracle.communications.platform.persistence.impl.FinderBean.findByJPQL(FinderBean.java:559)
at com.ora.entity.test.SortTest.main(SortTest.java:34)
Caused by: Exception [EclipseLink-8021] (Eclipse Persistence Services - 1.0 (Build 1.0 - 20080707)): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Error compiling the query Select c from DisConfig c where c.scanConfig is null Order By c.runReconciliation, line 1, column 63: invalid ORDER BY item c.runReconciliation of type boolean, expected expression of an orderable type.
at org.eclipse.persistence.exceptions.JPQLException.expectedOrderableOrderByItem(JPQLException.java:335)
at org.eclipse.persistence.internal.jpa.parsing.OrderByItemNode.validate(OrderByItemNode.java:43)
at org.eclipse.persistence.internal.jpa.parsing.OrderByNode.validate(OrderByNode.java:72)
at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:214)
at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:187)
at org.eclipse.persistence.internal.jpa.parsing.ParseTree.validate(ParseTree.java:177)
at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateReadQueryInternal(JPQLParseTree.java:110)
at org.eclipse.persistence.internal.jpa.parsing.JPQLParseTree.populateQuery(JPQLParseTree.java:84)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:170)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:134)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:95)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:80)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:733)
... 2 more



Edited by: svasan on Mar 11, 2009 8:08 AM, Posted Correct Stacktrace
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2009
Added on Mar 11 2009
3 comments
3,746 views