I have a following method:
@Transactional
public void saveUpdateAndDelete(Entity newEntity, Entity updatedEntity, long deleteEntityId) {
entityRepository.save(newEntity);
entityRepository.findById(updatedEntity.getId())
.ifPresent(e -> e.setName(updatedEntity.getName));
entityRepository.deleteById(deleteEntityId);
}
How can I assure that all statements in saveUpdateAndDelete
method will be executed within a single transaction?
Edit: the question purpose is to solve some implementation problem, not about how @Transactional
is handled by Spring by creating proxy classes, which is explained here: Spring - @Transactional - What happens in background?.