openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r723260 - in /openjpa/trunk/openjpa-slice/src: main/java/org/apache/openjpa/slice/jdbc/UniqueResultObjectProvider.java test/java/org/apache/openjpa/slice/TestQuery.java
Date Thu, 04 Dec 2008 09:09:35 GMT
Author: ppoddar
Date: Thu Dec  4 01:09:35 2008
New Revision: 723260

URL: http://svn.apache.org/viewvc?rev=723260&view=rev
Log:
OPENJPA-812: Consider case when aggreate result from a slice can be null

Modified:
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/UniqueResultObjectProvider.java
    openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/UniqueResultObjectProvider.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/UniqueResultObjectProvider.java?rev=723260&r1=723259&r2=723260&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/UniqueResultObjectProvider.java
(original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/UniqueResultObjectProvider.java
Thu Dec  4 01:09:35 2008
@@ -116,13 +116,16 @@
     Object count(Object current, Object other) {
         if (current == null)
             return other;
+        if (other == null)
+        	return current;
         return ((Number)current).longValue() + ((Number)other).longValue();
     }
     
     Object max(Object current, Object other) {
         if (current == null)
             return other;
-        
+        if (other == null)
+        	return current;
         return Math.max(((Number)current).doubleValue(), 
                 ((Number)other).doubleValue());
     }
@@ -130,6 +133,8 @@
     Object min(Object current, Object other) {
         if (current == null)
             return other;
+        if (other == null)
+        	return current;
         return Math.min(((Number)current).doubleValue(), 
                 ((Number)other).doubleValue());
     }
@@ -137,6 +142,8 @@
     Object sum(Object current, Object other) {
         if (current == null)
             return other;
+        if (other == null)
+        	return current;
         return (((Number)current).doubleValue() +
                 ((Number)other).doubleValue());
     }

Modified: openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java?rev=723260&r1=723259&r2=723260&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java (original)
+++ openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQuery.java Thu
Dec  4 01:09:35 2008
@@ -98,6 +98,15 @@
         assertEquals(max, max1);
     }
     
+    public void testAggregateQueryWithMissingValueFromSlice() {
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        Object max   = em.createQuery("SELECT MAX(p.value) FROM PObject p WHERE MOD(p.value,2)=0").getSingleResult();
+        em.getTransaction().rollback();
+        
+        assertEquals(VALUE_MAX, ((Number)max).intValue());
+    }
+
     public void testSetMaxResult() {
         EntityManager em = emf.createEntityManager();
         int limit = 3;



Mime
View raw message