I'm facing this scenario: I have three entities (EntA, EntB and EntC) EntA and EntB have the a Key< EntC> parameter. Also EntC has a List< String> parameter that holds the Keys of EntA and EntB as String.
In order to get the keys of any of the entities I first have to persist them (id field is auto-generated). So I'm doing this:
- Create and save EntC, this creates the Key< EntC> value I need for EntA and EntB.
- I create EntA and EntB using Key< EntC> and save them.
- Update EntC by adding Key< EntA> and Key< EntC> to the corresponding list. I found entities aren't updated in DS but re-written. So, I first fetch EntC, get its id which I use to create a new EntC entity that contains Key< EntA> and Key< EntB>. Finally, I delete the original EntC and save the new EntC.
I'd like to know if there's a better to approach to acomplish that. Also, is it possible that another entity gets the id of the original EntC entity after I delete it and before I save the new EntC entity?