Hi,
I’ve installed the optimistic locking addon and trying to use it for this use case, in a ticketing system i want to lock an entity when booking a seat and unlock right after. Just want to confirm if this is the proper usage, theres not much documentation and examples
@Autowired
private LockManager lockManager;
//
FetchPlan segFetchPlan = fetchPlanRepository.getFetchPlan(Segment.class, "segment-tickets");
Segment segment = dataManager.load(Segment.class)
.id(segmentId)
.fetchPlan(segFetchPlan)
.one();
try {
lockManager.lock(segment);
//execute some logic
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException("Exception message", e);
} finally {
lockManager.unlock(segment);
}
regards,