I have spring-boot
app with mybatis
as my ORM. I also use sqlserver 2012
.
I consider following scenario:
void foo () {
set current datasource as Datasource D1 (connected to database D1)
do some insert on table T1 in database D1
set current datasource as Datasource D2 (connected to database D2)
do some insert on table T1 (the same name) in database D2
}
I would like to be able to ensure that it always succees both queries. Otherwise (when at least one of them fails) transaction will be rollback (I mean no changes) in both databases (even if one of them query succeed).
I think that @Transactional
above foo()
is not sufficient.
Is it possible to gain this effect ?