So I am trying to implement the pessimistic lock in one of my POJO class and I have tried all the different methods mentioned in this.
This is in my controller:
@Transactional
public ModelAndView getList(Model model){
SGroup sGroup = maintainSGroupService.findGroupByID();
return new ModelAndView("th_List");
}
This is in my service class:
public SGroup findSGroupByID() {
SGroup group = null;
try {
group = submissionGroupRepository.findByObjectID(anObjectID);
}catch (Exception he) {
logger.error("Caught HibernateException in findSGroupByID().", he);
}
return group;
}
This is in my repository class:
@Lock(LockModeType.PESSIMISTIC_WRITE)
public SubmissionGroup findByObjectID(Long id);
I don't get any exception or anything But the problem is when I login from another id I am still able to access the same record. I should be getting PessimisticLockoutException. Is there anything I am missing?