How can I have multiple ways of generating rawId in spring for an entitiy in hibernate?

18 Views Asked by At

I have a situation of doing dual writes where I want to first save the object to a microservice, retrieve the rawId and then save it in the monolith as well. Upon doing application.setId(rawId) I get optimistic locking failure exception .

This whole thing will be behind a flag and will work only when the flag is true. If it is false, I want the application to be created using the existing rawId generation algorithm which is written in hibernate-mappings.xml.

Is there any way I can do it?

0

There are 0 best solutions below