java – `set-then-get` vs` get-then-set` in the context of the race condition?

You are comparing scenarios at two different levels.

Atomic construction handles atomic updates (Compare-and-swap / set) through the hardware platform / implementation. Some changes to being "Atomic" make the order of obtaining and configuration irrelevant to the outside world.

Database level updates are a bit on the top level. First look for an entity (as a user) and then use some conditional logic to decide whether to update or not. There is a time window between, and you have to implement your own methods to handle career conditions. You can block DB records, use a version counter, etc.