With Datastax java driver for cassandrausing @Accessor for select query, Can we filter columns in query itself instead of select * always
All the examples and docs I see select all the columns.
For example
Select column_A from table
As stated in this example you have query under your hand. There is a * and you can change it to whatever you like. So you can change * to column_A
only but pay attention that class under mapping must have same structure. Of course it must be valid CQL query with all partition and clustering columns.
So let's say that you need only first_name
of User
class. You would create User
class with only first_name
property and Accessor which is using mapped class under the hood will map only first_name
property and you will get list of User
objects with single property.
Good way to do it if you sometimes need full object and sometimes only handful of properties would be to create some kind of light mapper objects with subset of properties and use it where needed.