code: public String toSqlString(Object value) {
       if (value == null) {
          return "null";
       }
        
       String val = String.valueOf(value);
  
       if (value instanceof Integer ||
           value instanceof Float ||
           value instanceof Double ||
           value instanceof Long) {
         return val;
       } else if (value instanceof Boolean) {
          return "'" + ((Boolean) value ? "true" : "false") + "'";
       } else if (value instanceof Date) {
          return String.valueOf(((Date) value).getTime());
       } else {
         return "'" + val + "'"; // TODO escape special characters in val here
       }
     }
docs: Convert value object to sanitized SQL string
  @param value - the value object
  @return a string for use in an SQL statement
  @author Toby Kurien