changeset 345:7514fe89efef

Backend.getMasterArtifact: Limit result to one row. artifacts/trunk@3044 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 20 Oct 2011 10:13:46 +0000
parents be883e843539
children 2d525562fae9
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Oct 19 16:13:07 2011 +0000
+++ b/ChangeLog	Thu Oct 20 10:13:46 2011 +0000
@@ -1,3 +1,8 @@
+2011-10-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java(getMasterArtifact):
+	  Limit result set to one row.
+
 2011-10-19	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Fix accidentally corruptd key to sql statement.
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Wed Oct 19 16:13:07 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Oct 20 10:13:46 2011 +0000
@@ -1265,25 +1265,28 @@
             logger.debug("Invalid collection id: '" + collectionId + "'");
             return null;
         }
-        final List<String> uuid = new ArrayList<String>();
+        final String [] uuid = new String[1];
+
         SQLExecutor.Instance exec = sqlExecutor.new Instance() {
             public boolean doIt() throws SQLException {
                 // Fetch masters (oldest artifact) id.
                 prepareStatement(SQL_COLLECTIONS_OLDEST_ARTIFACT);
                 stmnt.setString(1, collectionId);
-                logger.debug("getMaster.execute");
+                stmnt.setMaxRows(1); //
                 result = stmnt.executeQuery();
                 if (!result.next()) {
                     logger.debug("No such collection: " + collectionId);
                     return false;
                 }
-                logger.debug("getMasterArtifact result.getString " + result.getString(1));
-                uuid.add(result.getString(1));
-                reset();
+                uuid[0] = result.getString(1);
+                if (logger.isDebugEnabled()) {
+                    logger.debug("getMasterArtifact result.getString " +
+                        uuid[0]);
+                }
                 return true;
             }
         };
-        return exec.runRead() ? uuid.get(0) : null;
+        return exec.runRead() ? uuid[0] : null;
     }
 
     public boolean deleteCollection(final String collectionId) {

http://dive4elements.wald.intevation.org