Hi,
First of all, please, target BBCode help link to a blank page... I had to
rewrite my post. (And [ code ] tag lets showing html br tags)
So, I'm trying to declare a NamedQuery in which I order the rows by the
result of the COALESCE function.
I'm using GF 3.0.1 b22, with EclipseLink 2.1.x
I tried many ways to do this, but every try failed :
*First try* : Declare a NamedQuery which looks like :
[quote]
SELECT o
FROM ...
LEFT JOIN ... as p
...
ORDER BY COALESCE(o.firstField, p.otherField)
[/quote]
Deployment fails :
[quote]
... line 1, column 679: unexpected token [COALESCE].
Internal Exception: NoViableAltException(15!=[1328:1: orderByItem returns
[Object node] : (n= stateFieldPathExpression (a= ASC | d= DESC | ) | i= IDENT
(a= ASC| d= DESC | ) );])
[/quote]
*Second try* :
[quote]
SELECT o, COALESCE(o.firstField, p.otherField) as myAlias
FROM ...
LEFT JOIN ... as p
...
ORDER BY myAlias
[/quote]
Deployment fails :
[quote]
java.lang.ClassCastException:
org.eclipse.persistence.internal.jpa.parsing.CoalesceNode cannot be cast to
org.eclipse.persistence.internal.jpa.parsing.AliasableNode
[/quote]
I tried replacing COALECE by FUNC('COALESCE', o.firstField, p.otherField),
and some other hacks, but I couldn't find one correct.
I really want to use JPQL and not native query to get my stuff ; but I'm
locked at this point.
Any clue is very welcome, thanks for all.
Olivier.
--
[Message sent by forum member 'laps']
View Post: http://forums.java.net/node/796239