title: InvalidTypeException: Invalid type for value 1 of CQL type text, expecting class java.lang.String but class [Ljava.lang.Object; provided
body: <p>I am trying to insert into Cassandra database using Datastax Java driver. But everytime I am getting below exception at <code>prBatchInsert.bind</code> line- </p>
  
  <pre><code>com.datastax.driver.core.exceptions.InvalidTypeException: Invalid type for value 1 of CQL type text, expecting class java.lang.String but class [Ljava.lang.Object; provided
  </code></pre>
  
  <p>Below is my method which accepts <code>userId</code> as the input and <code>attributes</code> as the <code>Map</code> which contains <code>key</code> as my <code>Column Name</code> and value as the actual value of that column</p>
  
  <pre><code>public void upsertAttributes(final String userId, final Map&lt;String, String&gt; attributes, final String columnFamily) {
  
      try {
          Set&lt;String&gt; keys = attributes.keySet();
          StringBuilder sqlPart1 = new StringBuilder(); //StringBuilder.append() is faster than concatenating Strings in a loop
          StringBuilder sqlPart2 = new StringBuilder();
  
          sqlPart1.append("INSERT INTO " + columnFamily + "(USER_ID ");
          sqlPart2.append(") VALUES ( ?");
  
          for (String k : keys) {
              sqlPart1.append(", "+k); //append each key
              sqlPart2.append(", ?");  //append an unknown value for each key
          }
          sqlPart2.append(") "); //Last parenthesis (and space?)
          String sql = sqlPart1.toString()+sqlPart2.toString();
  
          CassandraDatastaxConnection.getInstance();
          PreparedStatement prBatchInsert = CassandraDatastaxConnection.getSession().prepare(sql);
          prBatchInsert.setConsistencyLevel(ConsistencyLevel.ONE);        
  
          // this line is giving me an exception
          BoundStatement query = prBatchInsert.bind(userId, attributes.values().toArray(new Object[attributes.size()])); //Vararg methods can take an array (might need to cast it to String[]?).
  
          CassandraDatastaxConnection.getSession().executeAsync(query);
  
      } catch (InvalidQueryException e) {
          LOG.error("Invalid Query Exception in CassandraDatastaxClient::upsertAttributes "+e);
      } catch (Exception e) {
          LOG.error("Exception in CassandraDatastaxClient::upsertAttributes "+e);
      }
  }
  </code></pre>
  
  <p>What wrong I am doing here? Any thoughts?</p>