@Transactional 和 Spring 数据
@Transactional and Spring Data
到目前为止我的理解是,当您使用 @Transactional 注释时,任何失败都会导致操作回滚到其之前的 state.I 有这个方法可以使用 spring 将 Items 添加到引用中PagingAndSortingRepository 接口。
@Override
public Quotation createNewQuotation(PurchaseRequest purchaseRequest, Supplier supplier) {
Quotation quotation = new Quotation();
Date now = new Date(Calendar.getInstance().getTimeInMillis());
quotation.setQuotationDate(now);
quotation.setPurchaseRequest(purchaseRequest);
quotation.setSupplier(supplier);
quotationRepository.save(quotation);
return quotation;
}
当我在整体上放置一个@Transactional 注释时 class 并手动测试操作是否会回滚(通过不选择任何供应商),其他属性如 quotationDate、PurchaseRequest 仍然存储在数据库中。
我感觉我没有使用@Transactional 注释。可能是什么问题,我该如何解决?
感谢您的回复。
我通过在主 class 上添加 @EnableTransactionManagement
来完成这项工作。
我解决了
The bean 'purchaseRequestServiceImpl' could not be injected as a
'com.eprocurement.service.PurchaseRequestServiceImpl' because it is a
JDK dynamic proxy that implements:
com.eprocurement.service.PurchaseRequestService Action: Consider
injecting the bean as one of its interfaces or forcing the use of
CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync
and/or @EnableCaching.
通过在我的服务接口上放置 @Transactional
注释并 @autowiring
它而不是 @autowiring
我的实现 classes.
到目前为止我的理解是,当您使用 @Transactional 注释时,任何失败都会导致操作回滚到其之前的 state.I 有这个方法可以使用 spring 将 Items 添加到引用中PagingAndSortingRepository 接口。
@Override
public Quotation createNewQuotation(PurchaseRequest purchaseRequest, Supplier supplier) {
Quotation quotation = new Quotation();
Date now = new Date(Calendar.getInstance().getTimeInMillis());
quotation.setQuotationDate(now);
quotation.setPurchaseRequest(purchaseRequest);
quotation.setSupplier(supplier);
quotationRepository.save(quotation);
return quotation;
}
当我在整体上放置一个@Transactional 注释时 class 并手动测试操作是否会回滚(通过不选择任何供应商),其他属性如 quotationDate、PurchaseRequest 仍然存储在数据库中。
我感觉我没有使用@Transactional 注释。可能是什么问题,我该如何解决?
感谢您的回复。
我通过在主 class 上添加 @EnableTransactionManagement
来完成这项工作。
我解决了
The bean 'purchaseRequestServiceImpl' could not be injected as a 'com.eprocurement.service.PurchaseRequestServiceImpl' because it is a JDK dynamic proxy that implements: com.eprocurement.service.PurchaseRequestService Action: Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.
通过在我的服务接口上放置 @Transactional
注释并 @autowiring
它而不是 @autowiring
我的实现 classes.