【发布时间】:2021-04-19 14:12:54
【问题描述】:
我有以下方法:
@Transactional
public Store handle(Command command) {
Store store= mapper.map(command.getStoreDto(), Store.class);
Store persistedStore = storeService.save(store);
addressService.saveStoreAddress(store, command.getEmployeeId()); //this method is not crucial, should be called independently and in another transaction, without any rollback in case of exception
return persistedStore;
}
addressService.saveStoreAddress 并不重要——当这个方法抛出任何异常时,无论如何都应该保存 store (storeService.save(store);)。就我而言,最好的解决方案是什么?
【问题讨论】:
标签: spring-boot hibernate spring-transactions