this is my first post since I am convinced there is a better solution than mine. My question is rather a design question.
I use Spring Boot 2.1.x to store a user entity in a Cassandra database. This works well so far. It is stored with
- java generated uuid
- mail address
- salted bcrypt password
- some user defined types...
Well, in case somebody uses the login I will get the mail and the password to get the credentials.
For retrieving the user object I would expect some WHERE-clause with "select * from user where username = mail".
However, in this case mail must be the partition key in Cassandra. But, I want the user to be able to change her/his mail address and then it may not be part of the primary key of a Cassandra table.
My naive idea is to have an inverse table with a tuple (mail, java generated uuid) to lookup the user and then to load the user with the uuid.
I am just learning about handling Cassandra properly but in IMHO my design is crap.
This is what I have in my user bean.
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0, name = "id")
@JsonProperty("id")
private String id;
@PrimaryKeyColumn(type = PrimaryKeyType.CLUSTERED, ordinal = 1, name = "email")
@Email(message = "*Please provide a valid email")
@NotEmpty(message = "*Please provide an email")
@JsonProperty("email")
private String email;