[ https://issues.apache.org/jira/browse/JDO-652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16613253#comment-16613253 ]
Andy Jefferson commented on JDO-652: ------------------------------------ I've updated the DN prototype to match Craig's ideas / namings, namely *JDOQLTypedQuery* gains these methods {code:java} /** * Method to return an "IF (...) ... ELSE ..." expression for use in this query. * @param type The type returned by the IfElse. * @return The IfThenElse expression */ <V> IfThenElseExpression<V> ifThenElse(Class<V> type); /** * Method to return an "IF (...) ... ELSE ..." expression for use in this query. * @param type The type returned by the IfElse. * @param ifExpr If expression * @param ifValue Value to return when the if expression is met * @param elseValue Value to return when the if expression is not met * @return The IfThenElse expression */ <V> IfThenElseExpression<V> ifThenElse(Class<V> type, BooleanExpression ifExpr, V ifValue, V elseValue); /** * Method to return an "IF (...) ... ELSE ..." expression for use in this query. * @param type The type returned by the IfElse. * @param ifExpr If expression * @param ifValueExpr Expression for value to return when the if expression is met * @param elseValueExpr Expression for value to return when the if expression is not met * @return The IfThenElse expression */ <V> IfThenElseExpression<V> ifThenElse(Class<V> type, BooleanExpression ifExpr, Expression<V> ifValueExpr, Expression<V> elseValueExpr); {code} and there is now *IfThenElseExpression* as follows {code:java} public interface IfThenElseExpression<T> extends ComparableExpression<T> { /** * Method to add an "IF (...) ..." clause. * If called multiple times, will add extra "IF (...) ..." or "ELSE IF (...) ..." * @param ifExpr The if expression * @param value The return value * @return This expression */ IfThenElseExpression<T> when(BooleanExpression ifExpr, T value); /** * Method to add an "IF (...) ..." clause. * If called multiple times, will add extra "IF (...) ..." or "ELSE IF (...) ..." * @param ifExpr The if expression * @param value The return value expression * @return This expression */ IfThenElseExpression<T> when(BooleanExpression ifExpr, Expression<T> valueExpr); /** * Method to add the "ELSE ..." clause. * If called multiple times will replace the previous else clause * @param value The return value * @return This expression */ IfThenElseExpression<T> otherwise(T value); /** * Method to add the "ELSE ..." clause. * If called multiple times will replace the previous else clause * @param value The return value expression * @return This expression */ IfThenElseExpression<T> otherwise(Expression<T> valueExpr); } {code} The builder methods provided don't cater for the cases where the user wants to provide a literal for the "if" value and expression for the "else" value (and vice versa), but i'd put those as minority interest use-cases. > 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)