Ignore:
Timestamp:
08/23/13 16:23:28 (11 years ago)
Author:
olhsha
Message:

replacing String with StringBuilder? for the SQL request-strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/dao/impl/JdbcCachedRepresentationDao.java

    r3463 r3464  
    4949    public CachedRepresentationInfo getCachedRepresentationInfo(Number internalID) {
    5050
    51         String sql = "SELECT " + cachedRepresentationStar + " FROM " + cachedRepresentationTableName + " WHERE " + cached_representation_id + "= ? LIMIT 1";
    52         List<CachedRepresentationInfo> result = getSimpleJdbcTemplate().query(sql, cachedRepresentationRowMapper, internalID);
     51        StringBuilder sql = new StringBuilder("SELECT ");
     52        sql.append(cachedRepresentationStar).append(" FROM ").append(cachedRepresentationTableName).append(" WHERE ").append(cached_representation_id).append("= ? LIMIT 1");
     53        List<CachedRepresentationInfo> result = getSimpleJdbcTemplate().query(sql.toString(), cachedRepresentationRowMapper, internalID);
    5354
    5455        if (result.isEmpty()) {
     
    7374
    7475    private boolean cachedIsInUse(Number cachedID) {     
    75         String sql = "SELECT " + version_id + " FROM " + versionsCachedRepresentationsTableName + " WHERE " + cached_representation_id + "= ? LIMIT 1";
    76         List<Number> result = getSimpleJdbcTemplate().query(sql, versionIDRowMapper, cachedID);
     76        StringBuilder sql = new StringBuilder("SELECT ");
     77        sql.append(version_id).append(" FROM ").append(versionsCachedRepresentationsTableName).append(" WHERE ").append(cached_representation_id).append("= ? LIMIT 1");
     78        List<Number> result = getSimpleJdbcTemplate().query(sql.toString(), versionIDRowMapper, cachedID);
    7779        return (!result.isEmpty());
    7880    }
     
    8991        params.put("tool", cached.getTool());
    9092        params.put("type", cached.getType());
    91         String sql = "INSERT INTO " + cachedRepresentationTableName + "(" + external_id + "," + mime_type + "," + tool + "," + type_ + " ) VALUES (:externalId, :mime_type,  :tool, :type)";
    92         final int affectedRows = getSimpleJdbcTemplate().update(sql, params);
     93        StringBuilder sql = new StringBuilder("INSERT INTO ");
     94        sql.append(cachedRepresentationTableName).append("(").append(external_id).append(",").append(mime_type).append(",").append(tool).append("," ).append(type_).append(" ) VALUES (:externalId, :mime_type,  :tool, :type)");
     95        final int affectedRows = getSimpleJdbcTemplate().update(sql.toString(), params);
    9396        return (affectedRows > 0 ? getInternalID(externalIdentifier) : null);
    9497    }
     
    101104        }
    102105       
    103         String sql = "DELETE FROM " + cachedRepresentationTableName + " where " + cached_representation_id + " = ?";
    104         return  getSimpleJdbcTemplate().update(sql, internalID);
     106        StringBuilder sql = new StringBuilder("DELETE FROM ");
     107        sql.append(cachedRepresentationTableName).append(" WHERE ").append(cached_representation_id).append(" = ?");
     108        return  getSimpleJdbcTemplate().update(sql.toString(), internalID);
    105109    }
    106110   
Note: See TracChangeset for help on using the changeset viewer.