【发布时间】:2021-01-08 10:22:01
【问题描述】:
如何让两个 JPA 查询在同一个事务中运行?
请参见下面的示例。如果第二个查询失败,我希望回滚第一个查询。
@Bean
IntegrationFlow dbFlow() {
return IntegrationFlows.from("poiChannel")
.routeToRecipients(r -> r
.recipientFlow(
(f) -> f.handle(Jpa.outboundAdapter(entityManagerFactory)
.jpaQuery("delete from PointOfInterest"),
e -> e.transactional()
)
)
.recipientFlow(
(f) -> f.handle(Jpa.outboundAdapter(entityManagerFactory)
.entityClass(PointOfInterest.class),
e -> e.transactional(true)
)
)
)
.get();
}
【问题讨论】:
标签: spring-integration spring-integration-dsl