mirror of
https://github.com/google/nomulus
synced 2026-01-06 21:47:31 +00:00
Passing in an already-existing instance is an antipattern because it can lead to race conditions where something else modified the object in between when the pipeline loaded it and when you're saving it. The Write action should only be writing new entities. We cannot check IDs for the objects (some IDs are not autogenerated so they might exist already). We also cannot call `insert` on the objects because the underlying JPA `persist` call adds the input object to the persistence context, meaning that any modifications (e.g. updateTimestamp) are reflected in the input object. Beam doesn't allow modification of input objects.