Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

Ryan Quey avatar image
Ryan Quey asked Erick Ramirez edited

Why are clustering keys missing when instantiating Dao from InventoryMapper?

I am using the Cassandra Java Driver, v.4.6.1.

While creating an instance of my DAO instance, I hit the following error:

com.datastax.oss.driver.api.core.servererrors.InvalidQueryException: Some clustering keys are missing: primary_genre, feed_url

Those are indeed my clustering keys, however I'm not sure what they are missing from.

The error appears similar to this one, except the difference is that I didn't realize I was even hitting the db. The stack trace shows that this error comes up on the bottom line, where I'm creating a DAO instance:

InventoryMapper inventoryMapper = InventoryMapper.builder(db.session).build(); 
PodcastDao dao = inventoryMapper.podcastDao("podcast_analysis_tool", "podcasts_by_language");

Here is some of my other code, in case it's helpful

InventoryMapper class :

@Mapper
public interface InventoryMapper {
  @DaoFactory
  PodcastDao podcastDao(@DaoKeyspace String keyspace, @DaoTable String table);
}     

Class definition:

@Entity
@CqlName("podcasts_by_language")
public class Podcast {
   @PartitionKey
   private String language;
   @ClusteringColumn(1) 
   private String primaryGenre;
   @ClusteringColumn(2) 
   private String feedUrl;
   ...
}

CQL to define the table:

CREATE TABLE IF NOT EXISTS podcast_analysis_tool.podcasts_by_language (owner TEXT, name TEXT, image_url30 TEXT,image_url60 TEXT,image_url100 TEXT,image_url600 TEXT, api TEXT, api_id TEXT, api_url TEXT, country TEXT,feed_url TEXT, genres LIST<TEXT>, api_genre_ids LIST<TEXT>,primary_genre TEXT,release_date TIMESTAMP,explicit BOOLEAN,episode_count INT,rss_feed TEXT,found_by_queries List<frozen<Map<Text, Text>>>, description TEXT,summary TEXT,description_subtitle TEXT,webmaster TEXT,owner_email TEXT,author TEXT,language
TEXT,website_url TEXT,updated_at TIMESTAMP, PRIMARY KEY ((language), primary_genre, feed_url)) WITH CLUSTERING ORDER BY(primary_genre ASC, feed_url ASC);
java driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Ryan Quey avatar image
Ryan Quey answered

Found out the answer on my own:

In my PodcastDao class, the `@Update` method wasn't sending in all the clustering columns. In other words, even when just instantiating a DAO instance for a class, if the definitions aren't correct it will throw an error as if already performing the CQL query (in this case, throwing as if it had done an UPDATE).

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.