I am using Spring JPA + Hibernate. I have a master for creation data, which call many REST services. They are located in one @ApiV1RestController, and their implementation is in one @Service. At different steps, I need to add data, process it, and commit at the end.
Example:
REST 1: /addItems Adding item
Item item = new Item();
item.setDescr("test");
itemRepository.flush();
REST 2: /addLocs Adding locations
Loc loc = new Loc();
loc.setDescr("test");
locRepository.flush();
REST 3: /checkItemLocs Executing a stored procedure where i work with data from previous REST-s
Step n. Commit
How to make the rest work in one transaction. Now the commit is automatically performed at the end of each rest service
I tried to use flush and @transactional