← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7425: Fixed bug in HibernateProgramStore

 

------------------------------------------------------------
revno: 7425
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-27 11:20:13 +0200
message:
  Fixed bug in HibernateProgramStore
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.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-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java	2012-06-20 08:57:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java	2012-06-27 09:20:13 +0000
@@ -53,9 +53,10 @@
 
     @SuppressWarnings( "unchecked" )
     @Override
-    public Collection<Program> get( int type, OrganisationUnit orgunit )
+    public Collection<Program> get( int type, OrganisationUnit organisationUnit )
     {
-        return getCriteria( Restrictions.eq( "type", type ) ).createAlias( "organisationUnits", "orgunit" ).add(
-            Restrictions.eq( "orgunit.id", orgunit.getId() ) ).list();
+        final String hql = "from Program p where p.type = :type and :organisationUnit in elements(p.organisationUnits)";
+        
+        return getQuery( hql ).setInteger( "type", type ).setEntity( "organisationUnit", organisationUnit ).list();
     }
 }