0

I have been stuck while working with java-driver. I execute a CQL query and fetch all rows.

How do I get the key from the com.datastax.driver.core.Row object?

phact
  • 7,305
  • 23
  • 27
tomekkup
  • 353
  • 2
  • 14
  • 1
    Assuming you included the key column(s) in your select call, you retrieve them just like another column (getInt, getString, etc.) – Olivier Michallat Nov 24 '15 at 13:44
  • "execute a CQL query and fetch all rows" - That's usually not a good idea to do with Cassandra. I don't see anywhere in the Row or Rowset objects that returns that type of meta data...probably because it's assumed that if you're working with a ResultSet object in client code, that you've already queried by the key(s). – Aaron Nov 25 '15 at 17:11

1 Answers1

1

The same way as any other column, for example myRow.getString("myKey")

There are a bunch of helpfull methods in the Row class: https://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/Row.html

Andriy Kuba
  • 8,093
  • 2
  • 29
  • 46