Cassandra: @PrimaryKeyColumn(name = " ") can not set column name over attribute of entity's name

Here I declare an entity like this. I use Cassandra

@Table(value = "messages_by_id")
public class Email {
    @Id
    @PrimaryKeyColumn(name = "id",ordinal = 0, type = PrimaryKeyType.PARTITIONED)
    private UUID timeUUID;
    @CassandraType(type = CassandraType.Name.TEXT)
    private String from;
    @CassandraType(type = CassandraType.Name.LIST, typeArguments = CassandraType.Name.TEXT)
    private List<String> to;
    @CassandraType(type = CassandraType.Name.TEXT)
    private String subject;
    @CassandraType(type = CassandraType.Name.TEXT)
    private String body;

But then when created and shown in database it did not set name of Key column as "id" as set in @PrimaryKeyColumn but follow the attribute name is "timeUUID"

enter image description here If you want more info to resolve, don't hesitate to ask me.

Just give me away to set the column name by using annotation attribute. Is this related to JPA or Hibernate ?

Upvotes: 0

Views: 409

Answers (1)

Aaron
Aaron

Reputation: 57748

Chris' comment is correct. In your case, I would use the @PrimaryKey annotation, instead:

@Table("messages_by_id")
public class Email {
    @PrimaryKey("id")
    private UUID timeUUID;

For more info, I have an entity class called UserEntity.java which uses this example. It's also part of a much larger project (DataStax's E-Commerce Workshop) which contains ways to properly annotate primary keys in Cassandra.

Upvotes: 1

Related Questions