persistence@glassfish.java.net

Re: Computed Properties in QL

From: James Sutherland <jamesssss_at_yahoo.com>
Date: Tue, 10 Jun 2008 07:48:32 -0700 (PDT)

Do you mean computed on the database, or computed in Java?

JPQL is translated into SQL, so performing Java operations may be difficult.
You can use some database functions in JPQL, but these are fairly limited
and do not support user defined functions, nor does JPQL allow functions in
the select clause I believe.

see,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=219814
(if this is what you need please vote for the bug)

TopLink/EclipseLink internally uses QueryKeys defined in the
TopLink/EclipseLink ClassDescriptor to process JPQL attributes. Potentially
you could define a QueryKey in your descriptor for x. I think it would be
useful to have extended query keys that can do computations, feel free to
log an enhancement for this.



Markus KARG-3 wrote:
>
> Is there a way to use "computed properties" (transient getter methods) in
> QL?
>
> What I want to do is to have a method "String getX() {return "some
> computed value";}" to be called for each entity instance fetched by
> "SELECT o.x FROM MyEntity o".
>
> Is that possible?
>
> Thanks
>
> Markus
>


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Computed-Properties-in-QL-tp17749147p17757278.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.