users@glassfish.java.net

howto order by a CMR field in EJB-QL? (not allowed?)

From: Hans Prueller <hans.prueller_at_gmx.net>
Date: Fri, 8 Sep 2006 14:54:07 +0200

hi together!
 
I have been using an open source J2EE appserver for the last 4 years and
currently
I'm evaluating alternatives as I perhaps want to migrate to another product
within near future.
 
One problem I have is, that GlassFish does not allow ORDER BY clauses using
single-valued
CMR fields which is a critical requirement in my opinion.
 
Think of the following:
 
* @ejb:finder
 * signature= "java.util.Collection findAllSorted()"
 * query ="SELECT DISTINCT OBJECT(c) FROM SubscriberBean AS c ORDER BY
c.instance.name, c.msisdn"
 
Where "c.instance" is a CMR relation (n:1) to CMP EB InstanceBean. If I want
to deploy the .ear containing above
finder, I get an error message that this EJB-QL is violating the EJB-SPEC
which seems to be the case.
Then I tried to change the query to make it ejb-ql conform:
 
* @ejb:finder
 * signature= "java.util.Collection findAll()"
 * query ="SELECT DISTINCT OBJECT(c) FROM SubscriberBean AS c, IN
(c.instance) as inst ORDER BY inst.name, c.msisdn"
 
Which shouldn't be violating the spec, but I get a deployment error that
"c.instance is not a collection valued CMR field".
 
The appserver I am currently using works fine with both alternatives. Is
there really no way to sort a ejb-ql result by a cmr-eb's attribute?
 
Any help appreciated,
Hans
 
PS: I'm not sure how different GlassFish is from SUN AS9 (or if there is any
technical difference at all) but I did download glassfish
from sun.com - so I am running SUN AS9.