Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java	(revision 3463)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java	(revision 3464)
@@ -49,6 +49,7 @@
     public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID) {
 
-        String sql = "SELECT " + cachedRepresentationStar + " FROM " + cachedRepresentationTableName + " WHERE " + cached_representation_id + "= ? LIMIT 1";
-        List<CachedRepresentationInfo> result = getSimpleJdbcTemplate().query(sql, cachedRepresentationRowMapper, internalID);
+        StringBuilder sql = new StringBuilder("SELECT ");
+        sql.append(cachedRepresentationStar).append(" FROM ").append(cachedRepresentationTableName).append(" WHERE ").append(cached_representation_id).append("= ? LIMIT 1");
+        List<CachedRepresentationInfo> result = getSimpleJdbcTemplate().query(sql.toString(), cachedRepresentationRowMapper, internalID);
 
         if (result.isEmpty()) {
@@ -73,6 +74,7 @@
 
     private boolean cachedIsInUse(Number cachedID) {      
-        String sql = "SELECT " + version_id + " FROM " + versionsCachedRepresentationsTableName + " WHERE " + cached_representation_id + "= ? LIMIT 1";
-        List<Number> result = getSimpleJdbcTemplate().query(sql, versionIDRowMapper, cachedID);
+        StringBuilder sql = new StringBuilder("SELECT ");
+        sql.append(version_id).append(" FROM ").append(versionsCachedRepresentationsTableName).append(" WHERE ").append(cached_representation_id).append("= ? LIMIT 1");
+        List<Number> result = getSimpleJdbcTemplate().query(sql.toString(), versionIDRowMapper, cachedID);
         return (!result.isEmpty());
     }
@@ -89,6 +91,7 @@
         params.put("tool", cached.getTool());
         params.put("type", cached.getType());
-        String sql = "INSERT INTO " + cachedRepresentationTableName + "(" + external_id + "," + mime_type + "," + tool + "," + type_ + " ) VALUES (:externalId, :mime_type,  :tool, :type)";
-        final int affectedRows = getSimpleJdbcTemplate().update(sql, params);
+        StringBuilder sql = new StringBuilder("INSERT INTO ");
+        sql.append(cachedRepresentationTableName).append("(").append(external_id).append(",").append(mime_type).append(",").append(tool).append("," ).append(type_).append(" ) VALUES (:externalId, :mime_type,  :tool, :type)");
+        final int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params);
         return (affectedRows > 0 ? getInternalID(externalIdentifier) : null);
     }
@@ -101,6 +104,7 @@
         }
         
-        String sql = "DELETE FROM " + cachedRepresentationTableName + " where " + cached_representation_id + " = ?";
-        return  getSimpleJdbcTemplate().update(sql, internalID);
+        StringBuilder sql = new StringBuilder("DELETE FROM ");
+        sql.append(cachedRepresentationTableName).append(" WHERE ").append(cached_representation_id).append(" = ?");
+        return  getSimpleJdbcTemplate().update(sql.toString(), internalID);
     }
     
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java	(revision 3463)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcResourceDao.java	(revision 3464)
@@ -105,30 +105,23 @@
             return null;
         }
-        String sql = "SELECT " + internalIdName + " FROM " + resourceTableName + " WHERE " + external_id + "= ? LIMIT 1";
-        List<Number> sqlResult = getSimpleJdbcTemplate().query(sql, internalIDRowMapper, externalId.toString());
-
-        if (sqlResult.isEmpty()) {
-            return null;
-        }
-
-        Number result = sqlResult.get(0);
-        return result;
+        StringBuilder sql = new StringBuilder("SELECT ");
+        sql.append(internalIdName).append(" FROM ").append(resourceTableName).append(" WHERE ").append(external_id).append("= ? LIMIT 1");
+        List<Number> sqlResult = getSimpleJdbcTemplate().query(sql.toString(), internalIDRowMapper, externalId.toString());
+        return (sqlResult.isEmpty() ? null: sqlResult.get(0));
     }
 
     @Override
     public UUID getExternalID(Number internalId) {
-        String sql = "SELECT " + external_id + " FROM " + resourceTableName + " WHERE " + internalIdName + "= ? LIMIT 1";
-        List<UUID> sqlResult = getSimpleJdbcTemplate().query(sql, externalIDRowMapper, internalId);
-        if (sqlResult.isEmpty()) {
-            return null;
-        }
-
-        return (sqlResult.get(0));
+        StringBuilder sql = new StringBuilder("SELECT ");
+        sql.append(external_id).append(" FROM ").append(resourceTableName).append(" WHERE ").append(internalIdName).append("= ? LIMIT 1");
+        List<UUID> sqlResult = getSimpleJdbcTemplate().query(sql.toString(), externalIDRowMapper, internalId);
+        return (sqlResult.isEmpty() ? null : sqlResult.get(0));
     }
 
     /////////////////////////////////////////////////////
     protected XMLGregorianCalendar retrieveTimeStamp(Number internalID) {
-        String sqlTime = "SELECT " + time_stamp + " FROM " + resourceTableName + " WHERE " + internalIdName + "= ? LIMIT 1";
-        List<XMLGregorianCalendar> timeStamp = getSimpleJdbcTemplate().query(sqlTime, timeStampRowMapper, internalID);
+        StringBuilder sqlTime = new  StringBuilder("SELECT ");
+        sqlTime.append(time_stamp).append(" FROM ").append(resourceTableName).append(" WHERE ").append(internalIdName).append("= ? LIMIT 1");
+        List<XMLGregorianCalendar> timeStamp = getSimpleJdbcTemplate().query(sqlTime.toString(), timeStampRowMapper, internalID);
         if (timeStamp.isEmpty()) {
             return null;
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java	(revision 3463)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcSourceDao.java	(revision 3464)
@@ -51,6 +51,7 @@
     @Override
     public Source getSource(Number internalID) {
-        String sql = "SELECT " + sourceStar + "FROM " + sourceTableName + " WHERE " + source_id + " = ?";
-        List<Source> result = getSimpleJdbcTemplate().query(sql, sourceRowMapper, internalID);
+        StringBuilder sql = new StringBuilder("SELECT ");
+        sql.append(sourceStar).append(" FROM ").append(sourceTableName).append(" WHERE ").append(source_id).append("= ? LIMIT 1");
+        List<Source> result = getSimpleJdbcTemplate().query(sql.toString(), sourceRowMapper, internalID);
         return (!result.isEmpty() ? result.get(0) : null);
     }
@@ -74,4 +75,5 @@
     @Override
     public List<Number> retrieveVersionList(Number sourceID) {
+       
         String sql = "SELECT " + version_id + " FROM " + sourcesVersionsTableName + " WHERE " + source_id + " = ?";
         return getSimpleJdbcTemplate().query(sql, versionIDRowMapper, sourceID);
@@ -90,6 +92,9 @@
 
         String sourceIDs = makeListOfValues(sources);
-        String sql = "SELECT " + external_id + "," + link_uri + "," + version + " FROM " + sourceTableName + " WHERE " + source_id + " IN " + sourceIDs;
-        return getSimpleJdbcTemplate().query(sql, SourceInfoRowMapper);
+        
+        StringBuilder sql = new StringBuilder("SELECT ");
+        sql.append(external_id).append(",").append(link_uri).append(",").append(version).
+                append(" FROM ").append(sourceTableName).append(" WHERE ").append(source_id).append(" IN ").append(sourceIDs);
+        return getSimpleJdbcTemplate().query(sql.toString(), SourceInfoRowMapper);
     }
     private final RowMapper<SourceInfo> SourceInfoRowMapper = new RowMapper<SourceInfo>() {
@@ -113,11 +118,13 @@
     @Override
     public boolean sourceIsInUse(Number sourceID) {
-        String sqlAnnotations = "SELECT " + annotation_id + " FROM " + annotationsSourcesTableName + " WHERE " + source_id + "= ? LIMIT 1";
-        List<Number> resultAnnotations = getSimpleJdbcTemplate().query(sqlAnnotations, annotationIDRowMapper, sourceID);
+        StringBuilder sqlAnnotations = new StringBuilder("SELECT ");
+        sqlAnnotations.append(annotation_id).append(" FROM ").append(annotationsSourcesTableName).append(" WHERE ").append(source_id).append(" = ? LIMIT 1");
+        List<Number> resultAnnotations = getSimpleJdbcTemplate().query(sqlAnnotations.toString(), annotationIDRowMapper, sourceID);
         if (resultAnnotations.size() > 0) {
             return true;
-        }
-        String sqlVersions = "SELECT " + version_id + " FROM " + sourcesVersionsTableName + " WHERE " + source_id + "= ? LIMIT 1";
-        List<Number> resultVersions = getSimpleJdbcTemplate().query(sqlVersions, versionIDRowMapper, sourceID);
+        }        
+        StringBuilder sqlVersions = new StringBuilder("SELECT ");
+        sqlVersions.append(version_id).append(" FROM ").append(sourcesVersionsTableName).append(" WHERE ").append(source_id).append(" = ? LIMIT 1");
+        List<Number> resultVersions = getSimpleJdbcTemplate().query(sqlVersions.toString(), versionIDRowMapper, sourceID);
         return (resultVersions.size() > 0);
     }
@@ -134,6 +141,7 @@
         params.put("linkUri", source.getLink());
         params.put("version", source.getVersion());
-        String sql = "INSERT INTO " + sourceTableName + "(" + external_id + "," + link_uri + "," + version + " ) VALUES (:externalId, :linkUri,  :version)";
-        final int affectedRows = getSimpleJdbcTemplate().update(sql, params);  
+        StringBuilder sql = new StringBuilder("INSERT INTO ");
+        sql.append(sourceTableName).append("(").append(external_id).append(",").append(link_uri).append(",").append(version).append(" ) VALUES (:externalId, :linkUri,  :version)");
+        final int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params);  
         return (affectedRows>0 ? getInternalID(UUID.fromString(externalID.toString())) : null);
     }
@@ -146,6 +154,6 @@
         paramsJoint.put("sourceId", sourceID);
         paramsJoint.put("versionId", versionID);
-        String sqlJoint = "INSERT INTO " + sourcesVersionsTableName + "(" + source_id + "," + version_id + " ) VALUES (:sourceId, :versionId)";
-        return getSimpleJdbcTemplate().update(sqlJoint, paramsJoint);
+        StringBuilder sqlJoint = new StringBuilder("INSERT INTO ").append(sourcesVersionsTableName).append("(").append(source_id).append(",").append(version_id).append(" ) VALUES (:sourceId, :versionId)");
+        return getSimpleJdbcTemplate().update(sqlJoint.toString(), paramsJoint);
     }
    
@@ -156,6 +164,7 @@
             return 0;
         }
-        String sqlSourcesVersions = "DELETE FROM " + sourceTableName + " WHERE " + source_id + " = ? ";
-        return getSimpleJdbcTemplate().update(sqlSourcesVersions, internalID);
+        StringBuilder sqlSourcesVersions = new StringBuilder("DELETE FROM ");
+        sqlSourcesVersions.append(sourceTableName).append(" WHERE ").append(source_id).append(" = ? ");
+        return getSimpleJdbcTemplate().update(sqlSourcesVersions.toString(), internalID);
 
     }
@@ -165,6 +174,7 @@
     @Override
     public int deleteAllSourceVersion(Number internalID) {
-        String sqlSourcesVersions = "DELETE FROM " + sourcesVersionsTableName + " WHERE " + source_id + " = ?";
-        return getSimpleJdbcTemplate().update(sqlSourcesVersions, internalID);
+        StringBuilder sqlSourcesVersions = new StringBuilder("DELETE FROM ");
+        sqlSourcesVersions.append(sourcesVersionsTableName).append(" WHERE ").append(source_id).append(" = ?");
+        return getSimpleJdbcTemplate().update(sqlSourcesVersions.toString(), internalID);
 
     }
Index: /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java
===================================================================
--- /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java	(revision 3463)
+++ /DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcVersionDao.java	(revision 3464)
@@ -47,6 +47,7 @@
     public Version getVersion(Number internalID) {
 
-        String sql = "SELECT " + versionStar + " FROM " + versionTableName + " WHERE " + version_id + "= ? LIMIT 1";
-        List<Version> result = getSimpleJdbcTemplate().query(sql, versionRowMapper, internalID);
+        StringBuilder sql  = new StringBuilder("SELECT ");
+        sql.append(versionStar).append(" FROM ").append(versionTableName).append(" WHERE ").append(version_id).append("= ? LIMIT 1");
+        List<Version> result = getSimpleJdbcTemplate().query(sql.toString(), versionRowMapper, internalID);
         return (!result.isEmpty() ? result.get(0) : null);
     }
@@ -66,6 +67,7 @@
     @Override
     public List<Number> retrieveCachedRepresentationList(Number versionID) {
-        String sql = "SELECT DISTINCT " + cached_representation_id + " FROM " + versionsCachedRepresentationsTableName + " WHERE " + version_id + "= ?";
-        return getSimpleJdbcTemplate().query(sql, cachedIDRowMapper, versionID);
+        StringBuilder sql  = new StringBuilder("SELECT DISTINCT ");
+        sql.append(cached_representation_id).append(" FROM ").append(versionsCachedRepresentationsTableName).append(" WHERE ").append(version_id).append("= ?");
+        return getSimpleJdbcTemplate().query(sql.toString(), cachedIDRowMapper, versionID);
     }
 
@@ -76,11 +78,13 @@
     @Override
     public boolean versionIsInUse(Number versionsID) {
-        String sqlSources = "SELECT " + source_id + " FROM " + sourcesVersionsTableName + " WHERE " + version_id + "= ? LIMIT 1";
-        List<Number> resultSources = getSimpleJdbcTemplate().query(sqlSources, sourceIDRowMapper, versionsID);
+        StringBuilder sqlSources  = new StringBuilder("SELECT ");
+        sqlSources.append(source_id).append(" FROM ").append(sourcesVersionsTableName).append(" WHERE ").append(version_id).append("= ? LIMIT 1");
+        List<Number> resultSources = getSimpleJdbcTemplate().query(sqlSources.toString(), sourceIDRowMapper, versionsID);
         if (resultSources.size() > 0) {
             return true;
         }
-        String sqlVersions = "SELECT " + cached_representation_id + " FROM " + versionsCachedRepresentationsTableName + " WHERE " + version_id + "= ? LIMIT 1";
-        List<Number> resultCached = getSimpleJdbcTemplate().query(sqlVersions, cachedIDRowMapper, versionsID);
+        StringBuilder sqlCached  = new StringBuilder("SELECT ");
+        sqlCached.append(cached_representation_id).append(" FROM ").append(versionsCachedRepresentationsTableName).append(" WHERE ").append(version_id).append("= ? LIMIT 1");
+        List<Number> resultCached = getSimpleJdbcTemplate().query(sqlCached.toString(), cachedIDRowMapper, versionsID);
         return (resultCached.size() > 0) ;
     }
@@ -99,6 +103,7 @@
         //TODO: till the schema is fixed, version-text and version's external Id are the same (now version do not have URI's/ext id's)
         params.put("version", newExternalIdentifier);
-        String sql = "INSERT INTO " + versionTableName + "(" + external_id + "," + version + " ) VALUES (:externalId, :version)";
-        final int affectedRows = getSimpleJdbcTemplate().update(sql, params);
+        StringBuilder sql = new StringBuilder("INSERT INTO ");
+        sql.append(versionTableName).append("(").append(external_id).append(",").append(version).append(" ) VALUES (:externalId, :version)");
+        final int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params);
         return (affectedRows>0 ? getInternalID(externalIdentifier) : null);
     }
@@ -110,6 +115,7 @@
         params.put("versionId", versionID);
         params.put("cachedId", cachedID);
-        String sql = "INSERT INTO " + versionsCachedRepresentationsTableName + "(" + version_id + "," + cached_representation_id + " ) VALUES (:versionId, :cachedId)";
-        return getSimpleJdbcTemplate().update(sql, params);
+        StringBuilder sql = new StringBuilder("INSERT INTO ");
+        sql.append(versionsCachedRepresentationsTableName).append("(").append(version_id).append(",").append(cached_representation_id).append(" ) VALUES (:versionId, :cachedId)");
+        return getSimpleJdbcTemplate().update(sql.toString(), params);
     }
     
@@ -122,6 +128,7 @@
             return 0;
         }        
-        String sql = "DELETE FROM " + versionTableName + " where " + version_id + " = ?";
-        return getSimpleJdbcTemplate().update(sql, internalID);
+        StringBuilder sql = new StringBuilder("DELETE FROM ");
+        sql.append(versionTableName).append(" where ").append(version_id).append(" = ?");
+        return getSimpleJdbcTemplate().update(sql.toString(), internalID);
 
     }
