[ 
https://issues.apache.org/jira/browse/JDO-652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601154#comment-16601154
 ] 

Andy Jefferson edited comment on JDO-652 at 9/2/18 12:52 PM:
-------------------------------------------------------------

Re: mail to jdo-dev mailing list (which I don't subscribe to, and besides this 
is the issue in JIRA so ought to be the focal point for any dev discussion 
specific to this API),

 

*IF-THEN-ELSE* : this was added to JDOQL after the JDOQLTypedQuery API was 
designed. Consequently there is no handling for it. What QueryDSL does is 
likely the best option to use as a guide for how to provide it (see 
[http://www.querydsl.com/static/querydsl/4.1.3/reference/html_single/#d0e2105] 
and 
[http://www.querydsl.com/static/querydsl/4.1.4/apidocs/com/querydsl/core/types/dsl/CaseBuilder.html]
 ). Adapting it to JDO we could have something like this. Create a 
CaseExpression via builder method on JDOQLTypedQuery

CaseExpression caseExpr = JDOQLTypedQuery.newCaseExpression();

and then have methods on CaseExpression to

CaseExpression when(BooleanExpression condition, Expression valueExpr);

CaseExpression else(Expression valueExpr);

 

Or go via the QueryDSL CaseBuilder idea? If you have a better idea, propose 
something?

 

*Ordering NULLS FIRST/LAST* : again, not part of JDOQL when this API was 
designed. So we could do something like this

OrderExpression

    public enum OrderNullsPosition
    

{         FIRST,         LAST     }

    /**
      * Accessor for the position of nulls with this expression.
      * @return The nulls position (or null if not defined)
      */
     OrderNullsPosition getNullsPosition();


     /**
      * Method to set nulls to be ordered BEFORE non-nulls.
      * @return The order expression
      */
     OrderExpression<T> nullsFirst();

    /**
      * Method to set nulls to be ordered AFTER non-nulls.
      * @return The order expression
      */
     OrderExpression<T> nullsLast();

 

If you have a better idea, propose something?

 

*Map.get(Expression<K>)* : Was only added to JDOQL later in the dev cycle, so 
just add it?

 

*sqrt(), abs() etc for primitive wrappers* : A primitive wrapper is a 
NumericExpression, so are already part of the API. You likely need 
_datanucleus-jdo-query v5.0.6_ to see them, but that is not an error in the 
API, just the implementation having them later.

 

*StringExpression.startsWith(String, int)* : Was only added to JDOQL later in 
the dev cycle, so just add it. And while at it add the equivalent(s) taking in 
StringExpression, and NumericExpression.

 


was (Author: andy):
Re: mail to jdo-dev mailing list (which I don't subscribe to, and besides this 
is the issue in JIRA so ought to be the focal point for any dev discussion 
specific to this API),

 

*IF-THEN-ELSE* : this was added to JDOQL after the JDOQLTypedQuery API was 
designed. Consequently there is no handling for it. What QueryDSL does is 
likely the best option to use as a guide for how to provide it (see 
[http://www.querydsl.com/static/querydsl/4.1.3/reference/html_single/#d0e2105] 
and 
[http://www.querydsl.com/static/querydsl/4.1.4/apidocs/com/querydsl/core/types/dsl/CaseBuilder.html]
 ). Adapting it to JDO we could have something like this. Create a 
CaseExpression via builder method on JDOQLTypedQuery

CaseExpression caseExpr = JDOQLTypedQuery.newCaseExpression();

and then have methods on CaseExpression to

CaseExpression when(BooleanExpression condition, Expression valueExpr);

CaseExpression else(Expression valueExpr);

 

Or go via the QueryDSL CaseBuilder idea? If you have a better idea, propose 
something?

 

*Ordering NULLS FIRST/LAST* : again, not part of JDOQL when this API was 
designed. So we could do something like this

ComparableExpression
    /**
     * Method to set nulls to be ordered BEFORE non-nulls.
     * @return The order expression
     */
    OrderExpression<T> nullsFirst();

    /**
     * Method to set nulls to be ordered AFTER non-nulls.
     * @return The order expression
     */
    OrderExpression<T> nullsLast();

 

OrderExpression
    public enum OrderNullsPosition
    {
        FIRST,
        LAST
    }
    /**
     * Accessor for the position of nulls with this expression.
     * @return The nulls position (or null if not defined)
     */
    OrderNullsPosition getNullsPosition();

 

If you have a better idea, propose something?

 

*Map.get(Expression<K>)* : Was only added to JDOQL later in the dev cycle, so 
just add it?

 

*sqrt(), abs() etc for primitive wrappers* : A primitive wrapper is a 
NumericExpression, so are already part of the API. You likely need 
_datanucleus-jdo-query v5.0.6_ to see them, but that is not an error in the 
API, just the implementation having them later.

 

*StringExpression.startsWith(String, int)* : Was only added to JDOQL later in 
the dev cycle, so just add it. And while at it add the equivalent(s) taking in 
StringExpression, and NumericExpression.

 

> Provision of a typesafe refactor-friendly query capability for JDOQL
> --------------------------------------------------------------------
>
>                 Key: JDO-652
>                 URL: https://issues.apache.org/jira/browse/JDO-652
>             Project: JDO
>          Issue Type: New Feature
>          Components: api, specification, tck
>            Reporter: Andy Jefferson
>            Assignee: Michael Bouschen
>            Priority: Major
>             Fix For: JDO 3.2
>
>         Attachments: JDO-652-api-patch-Andy.txt, JDO-652-patch3.txt, 
> typesafe.patch, typesafe_manifest.patch
>
>
> There are various querying capabilities of this type around. JPA2 has its 
> Criteria query API. Third party solutions like QueryDSL also exist, in its 
> case providing a JDOQL implementation (as well as JPQL, and HQL). We should 
> seriously consider introducing something along these lines in the JDO2.4 
> timeframe. 
> There is a comparison of JPA Criteria with QueryDSL over at 
> http://source.mysema.com/forum/mvnforum/viewthread_thread,49



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to