[lsc-changes] r452 - lsc/trunk/src/main/java/org/lsc/service

jclarke at lsc-project.org jclarke at lsc-project.org
Wed Nov 18 19:41:36 CET 2009


Author: jclarke
Date: 2009-11-18 19:41:36 +0100 (Wed, 18 Nov 2009)
New Revision: 452

Modified:
   lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java
Log:
References #145. Better fix: make sure that the key used is unique by adding a counter. Applying on trunk.

Modified: lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java	2009-11-18 18:38:59 UTC (rev 451)
+++ lsc/trunk/src/main/java/org/lsc/service/AbstractJdbcService.java	2009-11-18 18:41:36 UTC (rev 452)
@@ -122,13 +122,21 @@
 		try {
 			List<HashMap<String, Object>> ids = (List<HashMap<String, Object>>) sqlMapper.queryForList(getRequestNameForList(), null);
 			Iterator<HashMap<String, Object>> idsIter = ids.iterator();
-			while (idsIter.hasNext()) {
+			for (int count = 1; idsIter.hasNext(); count++) {
 				HashMap<String, Object> idMap = idsIter.next();
 
 				// the key of the result Map is usally the DN
-				// since we don't have a DN from a database, we use a concatenation of all pivot attributes
-				// this is backwards compatible with the key being the pivot attribute (when there's only one)
-				String key = StringUtils.join(idMap.values().iterator(), ", ");
+				// since we don't have a DN from a database, we use a concatenation of:
+				//     - all pivot attributes
+				//     - a count of all objects (to make sure the key is unique)
+				// unless there's only one pivot, to be backwards compatible
+				String key;
+				if (idMap.values().size() == 1) {
+					key = idMap.values().iterator().next().toString();
+				}
+				else {
+					key = StringUtils.join(idMap.values().iterator(), ", ") + " (" + count + ")";
+				}
 				LscAttributes la = new LscAttributes(idMap);
 				ret.put(key, la);
 			}



More information about the lsc-changes mailing list