← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10554: Replaced statement manage with jdbc template in datavaluestore

 

------------------------------------------------------------
revno: 10554
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-15 16:01:14 +0200
message:
  Replaced statement manage with jdbc template in datavaluestore
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.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/aggregation/jdbc/JdbcAggregatedDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2012-11-24 15:42:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2013-04-15 14:01:14 +0000
@@ -37,7 +37,6 @@
 
 import org.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
-import org.amplecode.quick.mapper.ObjectMapper;
 import org.amplecode.quick.mapper.RowMapper;
 import org.hisp.dhis.aggregation.AggregatedDataValue;
 import org.hisp.dhis.aggregation.AggregatedDataValueStore;
@@ -487,30 +486,13 @@
     
     public DataValue getDataValue( int dataElementId, int categoryOptionComboId, int periodId, int sourceId ) //TODO remove
     {
-        final StatementHolder holder = statementManager.getHolder();
-        
-        final ObjectMapper<DataValue> mapper = new ObjectMapper<DataValue>();
-        
-        try
-        {
-            final String sql =
-                "SELECT * FROM datavalue " +
-                "WHERE dataelementid = " + dataElementId + " " +
-                "AND categoryoptioncomboid = " + categoryOptionComboId + " " +
-                "AND periodid = " + periodId + " " +
-                "AND sourceid = " + sourceId;
-            
-            final ResultSet resultSet = holder.getStatement().executeQuery( sql );
-            
-            return mapper.getObject( resultSet, new DataValueRowMapper() );
-        }
-        catch ( SQLException ex )
-        {
-            throw new RuntimeException( "Failed to get deflated data values", ex );
-        }
-        finally
-        {
-            holder.close();
-        }
+        final String sql =
+            "SELECT * FROM datavalue " +
+            "WHERE dataelementid = " + dataElementId + " " +
+            "AND categoryoptioncomboid = " + categoryOptionComboId + " " +
+            "AND periodid = " + periodId + " " +
+            "AND sourceid = " + sourceId;
+        
+        return jdbcTemplate.queryForObject( sql, new DataValueRowMapper() );
     }
 }