The dynamic inserts and updates are very useful for two reasons:
- reducing
OptimisticLockException
false positives on non-overlapping write-concern property sets
- avoiding some processing overhead related to updating indexes
However, the dynamic insert/update have drawbacks as well:
- you cannot reuse server-side and client-side prepared statements
- it reduces the likelihood of benefiting from batch updates] since the statement might change from one entity to the other.
So, there is no good way or bad way. It just depends on your data access patterns to figure out which of these two makes sense for a given entity.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…