This question has already been asked. But my present situation is a bit different, and I am hoping there are now better answers. So here goes:
I need a datastore entity to have two unique keys, one being the primary key.
Will the following suffice? I need that when I make a keys only query for the datastore to understand that I am referring to keyA
@Entity
public class UserAccount implements Serializable{
@Id
@GeneratedValue(strategy=GenericType.IDENTITY)
Key keyA;//based on email
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Key keyB;//randomly generated
//….other data
}
I need the datastore to help enforce the uniqueness of the keys so it is not enough to let keyB be a simple field that I manage myself.
UserAccounts with the same email... - Michael Técourt