[jira] [Commented] (JDO-652) Provision of a typesafe refactor-friendly query capability for JDOQL

2018-09-10 Thread Michael Bouschen (JIRA)


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

Michael Bouschen commented on JDO-652:
--

IfElseExpressionI think we have two separate issues here:

(1) Builder method taking 1 or 3 arguments

(2) Type of the IfThenElse expression: extending DoubleExpression?

I think we can resolve (1) later, because issue (2) is much more important.

Maybe my comment from above was misleading. I tried to build a JDOQLTypedQuery 
for "this.salary > (IF (this.department.name == 'Development') 15000.0 ELSE 
25000.0)". I came up with the following code:
{code:java}
JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class);
QEmployee cand = QEmployee.candidate();
IfElseExpression ifExpr = query.ifElseExpression(Double.class);
ifExpr.ifThen(cand.department.name.eq("Development"),15000.0).elseEnd(25000.0);
query.filter(cand.salary.gt(ifExpr));{code}
 

For me this looks ok (not looking at issue (1)), but it does not compile. So I 
played around with the generics in the interface IfThenElse, but I could not 
find a working solution. So I'm not proposing that "IfThenElse" should extend 
DoubleExpression. I was using the following interface definition:

 
{code:java}
interface IfThenElse extends ComparableExpression{code}
 

This supports IfTheElse and IfTheElse, too. But with Strings and 
Dates we do not have the above issues.

cand.salary is of type NumericExpression. Maybe the issue is the 
definition of NumericExpression:
{code:java}
interface NumericExpression extends ComparableExpression. {code}
So method gt in cand.salary.gt(ifExpr) expects an argument of type 
ComparableExpression which is not compatiple with 
IfElseExpression.

Andy, can you please try to compile the above query in your environment, just 
to see whether you run into a similar issue? If so, do you have an idea how to 
change the query API to make this working?

> 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)


[jira] [Comment Edited] (JDO-652) Provision of a typesafe refactor-friendly query capability for JDOQL

2018-09-10 Thread Michael Bouschen (JIRA)


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

Michael Bouschen edited comment on JDO-652 at 9/10/18 9:58 PM:
---

IfElseExpressionI think we have two separate issues here:

(1) Builder method taking 1 or 3 arguments

(2) Type of the IfThenElse expression: extending DoubleExpression?

I think we can resolve (1) later, because issue (2) is much more important.

Maybe my comment from above was misleading. I tried to build a JDOQLTypedQuery 
for "this.salary > (IF (this.department.name == 'Development') 15000.0 ELSE 
25000.0)". I came up with the following code:
{code:java}
JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class);
QEmployee cand = QEmployee.candidate();
IfElseExpression ifExpr = query.ifElseExpression(Double.class);
ifExpr.ifThen(cand.department.name.eq("Development"),15000.0).elseEnd(25000.0);
query.filter(cand.salary.gt(ifExpr));{code}
For me this looks ok (not looking at issue (1)), but it does not compile. So I 
played around with the generics in the interface IfThenElse, but I could not 
find a working solution. So I'm not proposing that "IfThenElse" should extend 
DoubleExpression. I was using the following interface definition:
{code:java}
interface IfThenElse extends ComparableExpression{code}
This supports IfTheElse and IfTheElse, too. But with Strings and 
Dates we do not have the above issues.

cand.salary is of type NumericExpression. Maybe the issue is the 
definition of NumericExpression:
{code:java}
interface NumericExpression extends ComparableExpression. {code}
So method gt in cand.salary.gt(ifExpr) expects an argument of type 
ComparableExpression which is not compatiple with 
IfElseExpression.

Andy, can you please try to compile the above query in your environment, just 
to see whether you run into a similar issue? If so, do you have an idea how to 
change the query API to make this working?


was (Author: mbo):
IfElseExpressionI think we have two separate issues here:

(1) Builder method taking 1 or 3 arguments

(2) Type of the IfThenElse expression: extending DoubleExpression?

I think we can resolve (1) later, because issue (2) is much more important.

Maybe my comment from above was misleading. I tried to build a JDOQLTypedQuery 
for "this.salary > (IF (this.department.name == 'Development') 15000.0 ELSE 
25000.0)". I came up with the following code:
{code:java}
JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class);
QEmployee cand = QEmployee.candidate();
IfElseExpression ifExpr = query.ifElseExpression(Double.class);
ifExpr.ifThen(cand.department.name.eq("Development"),15000.0).elseEnd(25000.0);
query.filter(cand.salary.gt(ifExpr));{code}
 

For me this looks ok (not looking at issue (1)), but it does not compile. So I 
played around with the generics in the interface IfThenElse, but I could not 
find a working solution. So I'm not proposing that "IfThenElse" should extend 
DoubleExpression. I was using the following interface definition:

 
{code:java}
interface IfThenElse extends ComparableExpression{code}
 

This supports IfTheElse and IfTheElse, too. But with Strings and 
Dates we do not have the above issues.

cand.salary is of type NumericExpression. Maybe the issue is the 
definition of NumericExpression:
{code:java}
interface NumericExpression extends ComparableExpression. {code}
So method gt in cand.salary.gt(ifExpr) expects an argument of type 
ComparableExpression which is not compatiple with 
IfElseExpression.

Andy, can you please try to compile the above query in your environment, just 
to see whether you run into a similar issue? If so, do you have an idea how to 
change the query API to make this working?

> 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)


[jira] [Comment Edited] (JDO-652) Provision of a typesafe refactor-friendly query capability for JDOQL

2018-09-10 Thread Michael Bouschen (JIRA)


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

Michael Bouschen edited comment on JDO-652 at 9/10/18 8:18 PM:
---

Thanks for the link Andy.

Following your proposal, I'm struggling with numeric types. Suppose I have an 
Employee query with filter:
"this.salary > (IF (this.department.name == 'Development') 15000.0 ELSE 
25000.0)". 
Then the JDOQLTypedQuery would look like
{noformat}
JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class);
QEmployee cand = QEmployee.candidate();
IfElseExpression ifExpr = query.ifElseExpression(Double.class);
ifExpr.ifThen(cand.department.name.eq("Development"), 15000.0).elseEnd(25000.0);
query.filter(cand.salary.gt(ifExpr));{noformat}
But the expression "cand.salary.gt(ifExpr)" does not compile. The compiler 
complains that there is not method gt taking a IfElseExpression. It 
would compile if the gt argument would be of type IfElseExpression.

Do you have an idea?


was (Author: mbo):
Thanks for the link Andy.

Following your proposal, I'm struggling with numeric types. Suppose I have an 
Employee query with filter: "this.salary > (IF (this.department.name == 
'Development') 15000.0 ELSE 25000.0)". Then the JDOQLTypedQuery would look like
{noformat}
JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class);
QEmployee cand = QEmployee.candidate();
IfElseExpression ifExpr = query.ifElseExpression(Double.class);
ifExpr.ifThen(cand.department.name.eq("Development"), 15000.0).elseEnd(25000.0);
query.filter(cand.salary.gt(ifExpr));{noformat}
But the expression "cand.salary.gt(ifExpr)" does not compile. The compiler 
complains that there is not method gt taking a IfElseExpression. It 
would compile if the gt argumnet would be of type IfElseExpression.

Do you have an idea?

> 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)


[jira] [Commented] (JDO-652) Provision of a typesafe refactor-friendly query capability for JDOQL

2018-09-10 Thread Andy Jefferson (JIRA)


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

Andy Jefferson commented on JDO-652:


And how is the Java API to know about "Number" when you define the type as 
"Double"? The "IfElseExpression" represents the type that it returns. You 
passed "Double" to the builder method, not "Number".

 

Why would the builder method take 3 arguments? An "If-Else" can have multiple 
"if"s and one "else". Specifying the "if-then" clauses individually makes it 
more fluent IMHO.

 

I can't see how "IfThenElse" can extend DoubleExpression ... because the type 
is "IfThenElse" ... i.e dependent on the type that it returns. And if the 
"If-Else" is returning a String? or a Date? IfElseNumeric, IfElseString and so 
on? (which makes it way less extensible).

Why not provide some code that demonstrates how that will work (and preferably 
an implementation, to go in 
[https://github.com/datanucleus/datanucleus-api-jdo/blob/master/src/main/java/org/datanucleus/api/jdo/query/IfElseExpressionImpl.java]
  )

> 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)