0

I want to update the DB and a server with some new data in one transaction.

I'm using java 8 and i was looking for Java transaction API.

I have found JTA but saw no code example. Can someone please link to one?

I saw this post and post

but there were about DB transaction and had no code example.

I want to make the transaction at a higher lever than the DAL level

as it wraps the peer-server update as well.

private void updateDbAndServer() throws Exception {



        if (rulesUiRepository.updateRulesUiSnapshot(nonSplittedRulesSnapshot) == -1)
            throw new RuntimeException("cannot save ui snapshot in DB");

        Map<RuleConditionBl, RtRule> splittedMap = nonSplittedRulesSnapshot.toSplittedMap();
        anotherService.updateConfig(splittedMap);
    }
Community
  • 1
  • 1
Elad Benda2
  • 13,852
  • 29
  • 82
  • 157

1 Answers1

0

I think the Spring Transaction API is very easy to use and allows you to concentrate about your businesses logic. The API is used in a declarative form. Check this for more info.

rvillablanca
  • 1,606
  • 3
  • 21
  • 34