I am working on Cassandra Spring-data module using Scala. I have created domain model & setup crud repository.
Spring data repository is setup as below:
@Repository
trait SampleRepository extends CassandraRepository[Sample, SampleKey]
Table domain model is setup as below:
@Table
case class Sample(@PrimaryKey
sampleKey: SampleKey,
@Column("surName")
surName: String)
Primary Key is composite key. Id column as Partition key. name column as Cluster key
@PrimaryKeyClass
case class SampleKey(
@PrimaryKeyColumn( `type` = PrimaryKeyType.PARTITIONED, ordinal = 0, name = "id")
id: Int,
@PrimaryKeyColumn( `type` = PrimaryKeyType.CLUSTERED, ordinal = 1, name = "name")
name: String
)
In scala type is a valid keyword hence used backward quotes. I am expecting this to work but when I start the application but I get
Suppressed: org.springframework.data.mapping.MappingException: Composite primary key type [com.barclays.decisionstore.trac.model.SampleKey] has no fields annotated with @PrimaryKeyColumn
at org.springframework.data.cassandra.core.mapping.PrimaryKeyClassEntityMetadataVerifier.verify(PrimaryKeyClassEntityMetadataVerifier.java:91)
... 262 common frames omitted
Suppressed: org.springframework.data.mapping.MappingException: At least one of the @PrimaryKeyColumn annotations must have a type of PARTITIONED
at org.springframework.data.cassandra.core.mapping.PrimaryKeyClassEntityMetadataVerifier.verify(PrimaryKeyClassEntityMetadataVerifier.java:98)
... 262 common frames omitted
This means type parameter to annotation is not recognized by Spring-Data.
The same code with java model classes works without issue.
Would appreciate any pointers or substitute to solve this.