/** * Create the partition key. * * @throws IllegalStateException if no fields have been added, * or the partitioning is known and not all fields have been added. */ public PartitionKey build() { if (fields.isEmpty()) { throw new IllegalStateException("Partition key cannot be empty."); } if (partitioning != null && !partitioning.getFields().keySet().equals(fields.keySet())) { throw new IllegalStateException(String.format( "Partition key is incomplete: It only contains fields %s, but the partitioning requires %s", fields.keySet(), partitioning.getFields().keySet())); } return new PartitionKey(fields); } }
Map<String, String> props = new HashMap<>(); props.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0); emf = Persistence.createEntityManagerFactory("cass_pu", props); ProductionRecord pr = new ProductionRecord(); pr.setSolrQuery("some solr query"); pr.setAdditionColumn("col1"); ClusteringKey ck = new ClusteringKey(); ck.setClusteringKey(UUID.randomUUID()); PartitionKey pk = new PartitionKey(); pk.setKey1("k1"); pk.setKey2("k2"); pk.setKey3("k3"); ck.setKey(pk); pr.setClusteringkey(ck); em.persist(pr);