I'm working on mapping two tables with minimal differences in Cassandra, however Kundera is failing to map my model correctly (I have it configured to validate mappings against tables on EntityManager creation). Given the following compound key (structured according to these directions, since paging is desired and additionally using the Datastax Driver:
CQL table creates have the following primary key for both tables:
PRIMARY KEY ((key1, key2, key3, key4, key5, key6, key7, key8, key9, key10, key11), "clusteringKey")
PartitionKey:
@Embeddable
public class PartitionKey {
@Column
private key1
//repeat for 11 more keys
}
ClusteringKey:
@Embeddable
public class ClusteringKey {
@Embedded
private PartitionKey key;
@Column
private UUID clusteringKey;
}
Properties load for CQL3:
public static EntityManagerFactory getEntityManagerFactory() throws IOException {
if(entityManagerFactory == null) {
entityManagerFactory = Persistence.createEntityManagerFactory("cassandra_pu",getProperties());
}
return entityManagerFactory;
}
public static Properties getProperties() throws IOException {
if(properties == null) {
properties = new Properties();
properties.load(Application.class.getResourceAsStream("/application.properties"));
properties.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
}
return properties;
}
I have attempted two models so far.
The first case:
SuperRecord:
@MappedSuperClass
public abstract class SuperRecord {
@EmbeddedId
private ClusteringKey clusteringkey;
//Additional Fields
}
//extended by StagingRecord, ProductionRecord
While ClusteringKey itself maps properly, nothing related to PartitionKey maps at all.
In my second attempt:
SuperRecord:
@MappedSuperClass
public abstract class SuperRecord {
//Common fields excluding keys
}
StagingRecord:
@Entity
public class StagingRecord extends SuperRecord {
@EmbeddedId
private ClusteringKey key;
}
ProductionRecord:
@Entity
public class ProductionRecord extends SuperRecord {
@EmbeddedId
private ClusteringKey key;
@Column(name="solr_query")
private String solrQuery;
}
In this attempt, while my clustering key maps, my partitionkey maps as a singular binary Object, rather than its constituent columns as desired.
What is preventing my PartitionKey from appropriately mapping, and how do I fix it?
Edit:
After distributing the superclass fields, I found that the @MappedSuperclass
is not a factor in my issue; only the nested @Embeddeds
. Additionally, if I were to merge the PartitionKey and ClusteringKey classes, the mapping will pass validation (though it would fail to correctly build the token method signature in the generated CQL for pagination, since my model no longer matches the expectation for that functionality).