← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19566: add flushing to ouService.updatePaths/ouService.forceUpdatePaths

 

------------------------------------------------------------
revno: 19566
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-07-08 09:38:46 +0700
message:
  add flushing to ouService.updatePaths/ouService.forceUpdatePaths
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.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/organisationunit/hibernate/HibernateOrganisationUnitStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-07-07 14:54:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-07-08 02:38:46 +0000
@@ -39,6 +39,7 @@
 import org.hisp.dhis.common.AuditLogUtil;
 import org.hisp.dhis.common.SetMap;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.dbms.DbmsManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
@@ -73,6 +74,9 @@
     @Autowired
     private CurrentUserService currentUserService;
 
+    @Autowired
+    private DbmsManager dbmsManager;
+
     // -------------------------------------------------------------------------
     // OrganisationUnit
     // -------------------------------------------------------------------------
@@ -340,12 +344,19 @@
     {
         List<OrganisationUnit> organisationUnits = new ArrayList<>( getQuery( "from OrganisationUnit ou where ou.path IS NULL" ).list() );
         Session session = sessionFactory.getCurrentSession();
+        int counter = 0;
 
         // use SF directly since we don't need to check for access etc here, just a simple update with no changes (so that path gets re-generated)
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
-            organisationUnit.setAutoFields();
             session.update( organisationUnit );
+
+            if ( (counter % 400) == 0 )
+            {
+                dbmsManager.clearSession();
+            }
+
+            counter++;
         }
     }
 
@@ -355,12 +366,19 @@
     {
         List<OrganisationUnit> organisationUnits = new ArrayList<>( getQuery( "from OrganisationUnit" ).list() );
         Session session = sessionFactory.getCurrentSession();
+        int counter = 0;
 
         // use SF directly since we don't need to check for access etc here, just a simple update with no changes (so that path gets re-generated)
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
-            organisationUnit.setAutoFields();
             session.update( organisationUnit );
+
+            if ( (counter % 400) == 0 )
+            {
+                dbmsManager.clearSession();
+            }
+
+            counter++;
         }
     }
 }