← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18601: HibernateDataApprovalStore: move subquery references to main query tables from join to where clau...

 

------------------------------------------------------------
revno: 18601
committer: jimgrace@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2015-03-13 12:45:17 -0400
message:
  HibernateDataApprovalStore: move subquery references to main query tables from join to where clause for H2 compatibility
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2015-03-12 18:00:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2015-03-13 16:45:17 +0000
@@ -328,8 +328,8 @@
                     "left join dataapproval da on da.organisationunitid = ous.organisationunitid " +
                     "and da.dataapprovallevelid = " + dal.getId() + " and da.periodid in (" + periodIds + ") " +
                     "and da.datasetid in (" + dataSetIds + ") " +
+                    "where ous.idlevel" + orgUnitLevel + " = o.organisationunitid " +
                     "and da.attributeoptioncomboid = cocco.categoryoptioncomboid " +
-                    "where ous.idlevel" + orgUnitLevel + " = o.organisationunitid " +
                     "and ous.level = " + dal.getOrgUnitLevel() + " " +
                     "and ( da.dataapprovalid is null " + ( acceptanceRequiredForApproval ? "or not da.accepted " : "" ) + ") )";
                 break;
@@ -349,16 +349,16 @@
         final String sql =
             "select cocco.categoryoptioncomboid, o.organisationunitid, " +
             "(select min(coalesce(dal.level, 0)) from period p " +
-            "left join dataapproval da on da.datasetid in (" + dataSetIds + ") and da.periodid = p.periodid " +
-                    "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " +
+                "left join dataapproval da on da.datasetid in (" + dataSetIds + ") and da.periodid = p.periodid " +
                 "left join dataapprovallevel dal on dal.dataapprovallevelid = da.dataapprovallevelid " +
                 "where p.periodid in (" + periodIds + ") " +
+                "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " +
             ") as highest_approved_level, " +
             "(select substring(min(concat(100000 + coalesce(dal.level, 0), coalesce(da.accepted, FALSE))) from 7) from period p " +
                 "left join dataapproval da on da.datasetid in (" + dataSetIds + ") and da.periodid = p.periodid " +
-                    "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " +
                 "left join dataapprovallevel dal on dal.dataapprovallevelid = da.dataapprovallevelid " +
                 "where p.periodid in (" + periodIds + ") " +
+                "and da.attributeoptioncomboid = cocco.categoryoptioncomboid and da.organisationunitid = o.organisationunitid " +
             ") as accepted_at_highest_level, " +
             readyBelowSubquery + " as ready_below, " +
             approvedAboveSubquery + " as approved_above " +