Bulk & History
Distinguish between general save with save lifecycle applied and the behavior of bulk insert/upsert, remove backup, and history snapshot.
save / saveAll
save(entity)
Use insertOne if there is no id, and _id based replaceOne(..., upsert=true) if there is an id.
saveAll(...)
Performs save() for each entity, so beforePersist/afterPersist lifecycle hooks are applied.
Bulk API selection
saveAllBulk
Bulk insert based on insertMany. This is not an API for updating existing ids.
saveAllBulkUpsert
If the entity id is absent, perform insert; if present, perform _id filter + $set + upsert.
saveAllBulkUpsertByKey
Upsert based on business composite keys. If any key is missing, the entity is treated as an insert.
Entity delete and remove backup
backup을 활성화하면 <sourceCollection>_remove collection을 사용합니다. delete와 backup을 하나의 원자 작업으로 묶어야 한다면 호출 측에서 getTxJob(...) transaction 범위를 잡습니다.
History snapshot
createHistory는 현재 MongoExecutionContext.write(...) 결과를 deep copy하고 _id를 제거한 뒤 <sourceCollection>_history 또는 지정한 prefix collection에 insert합니다. history write도 save lifecycle hook을 호출하지 않습니다.