State Appears as “” blank, when handling update operation in commandhandler, which results in creation of new entity instead of updating the existing ESE
In other words how does kalix know, which entity instance to update, based on mere input?
The entity id or key is specified in the command message.
For protocol-first, selecting protobuf message fields using the
(kalix.field).entity_key annotation. See messages for entities.
For code-first, specifying request parameters to use for the id. See identifying the entity.
I tried that, but it created a new primary key instead of updating the existing one
but it created a new primary key instead of updating the existing one
What is creating the entity key? If you’re using the generated entity keys, then it will generate a new key for each command message that has a generator. The expected pattern is to have an initial message that will generate a new random unique key, return that key identifier in the response, and then use the generated key for subsequent messages to the same entity instance.
Could you otherwise provide an example that demonstrates what you’re seeing?
Sorry for the trouble, but the key attribute is sort of a foreign key, what was surprising to me was, the order of the key attribute in all the entities was 1 except the one which had this issue, I gave it index 1 and voila it worked.
Good to hear it’s working now.
We’d expect it to pick up the keys based on the annotations, regardless of the index. We’ll follow up to check what’s happening here.
If it’s a composite key, combining multiple fields, then it is dependent on the order.