You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Vera Filippova (JIRA)" <ji...@apache.org> on 2010/09/15 11:09:32 UTC
[jira] Created: (OPENJPA-1794) Result of aggregate function MAX is
0 on empty table (instead of NULL).
Result of aggregate function MAX is 0 on empty table (instead of NULL).
-----------------------------------------------------------------------
Key: OPENJPA-1794
URL: https://issues.apache.org/jira/browse/OPENJPA-1794
Project: OpenJPA
Issue Type: Bug
Components: query
Affects Versions: 2.0.0
Reporter: Vera Filippova
Below is a snippet of a test case... the max should be null, but is zero.
Object count = em.createQuery("Select count(p.pk) from Entity1 p where 1=1").getSingleResult();
Object max = em.createQuery("Select max(p.pk) from Entity1 p where 1=1").getSingleResult();
System.out.println("count:"+count+ " max:"+max);
> count:0 max:0
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (OPENJPA-1794) Result of aggregate function MAX
is 0 on empty table (instead of NULL).
Posted by "Rick Curtis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-1794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12909731#action_12909731 ]
Rick Curtis commented on OPENJPA-1794:
--------------------------------------
Per the spec :
> If SUM, AVG, MAX, or MIN is used, and there are no values to which the aggregate function can be applied, the result of the aggregate function is NULL.
Something else to muddy the waters....
> The Java type that is contained in the result of a query using an aggregate function is as follows:
> ...
> *MAX, MIN return the type of the state field to which they are applied.
In the example detailed above, lets say the p.pk field is a primitive long... A NULL primitive is zero so in that case, it would appear that we are working properly. If p.pk is a java.lang.Long, we are not.
> Result of aggregate function MAX is 0 on empty table (instead of NULL).
> -----------------------------------------------------------------------
>
> Key: OPENJPA-1794
> URL: https://issues.apache.org/jira/browse/OPENJPA-1794
> Project: OpenJPA
> Issue Type: Bug
> Components: query
> Affects Versions: 2.0.0
> Reporter: Vera Filippova
>
> Below is a snippet of a test case... the max should be null, but is zero.
> Object count = em.createQuery("Select count(p.pk) from Entity1 p where 1=1").getSingleResult();
> Object max = em.createQuery("Select max(p.pk) from Entity1 p where 1=1").getSingleResult();
> System.out.println("count:"+count+ " max:"+max);
> > count:0 max:0
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (OPENJPA-1794) Result of aggregate function MAX
is 0 on empty table (instead of NULL).
Posted by "Vera Filippova (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-1794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910602#action_12910602 ]
Vera Filippova commented on OPENJPA-1794:
-----------------------------------------
it's NULL for Integer field.
> Result of aggregate function MAX is 0 on empty table (instead of NULL).
> -----------------------------------------------------------------------
>
> Key: OPENJPA-1794
> URL: https://issues.apache.org/jira/browse/OPENJPA-1794
> Project: OpenJPA
> Issue Type: Bug
> Components: query
> Affects Versions: 2.0.0
> Reporter: Vera Filippova
>
> Below is a snippet of a test case... the max should be null, but is zero.
> Object count = em.createQuery("Select count(p.pk) from Entity1 p where 1=1").getSingleResult();
> Object max = em.createQuery("Select max(p.pk) from Entity1 p where 1=1").getSingleResult();
> System.out.println("count:"+count+ " max:"+max);
> > count:0 max:0
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (OPENJPA-1794) Result of aggregate
function MAX is 0 on empty table (instead of NULL).
Posted by "Vera Filippova (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-1794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910602#action_12910602 ]
Vera Filippova edited comment on OPENJPA-1794 at 10/4/10 10:38 AM:
-------------------------------------------------------------------
it's 0 for Integer field.
was (Author: oakjumper):
it's NULL for Integer field.
> Result of aggregate function MAX is 0 on empty table (instead of NULL).
> -----------------------------------------------------------------------
>
> Key: OPENJPA-1794
> URL: https://issues.apache.org/jira/browse/OPENJPA-1794
> Project: OpenJPA
> Issue Type: Bug
> Components: query
> Affects Versions: 2.0.0
> Reporter: Vera Filippova
>
> Below is a snippet of a test case... the max should be null, but is zero.
> Object count = em.createQuery("Select count(p.pk) from Entity1 p where 1=1").getSingleResult();
> Object max = em.createQuery("Select max(p.pk) from Entity1 p where 1=1").getSingleResult();
> System.out.println("count:"+count+ " max:"+max);
> > count:0 max:0
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.