title: How To Use Optimistic Locking in Spring MVC
body: <p>I have been developing blog application using Spring MVC + Spring Data JPA + Hibernate. Now I have a problem with optimistic locking mechanism. 
  I will share a piece of code below. 
     I have added <strong>@Version</strong> annotation to entity. Than I am using two different browser to update same record at same time. Every time I perform the save action it increases the versioon +1 and updates data. But <strong>doesnt throw any exception</strong> 
  As you know , expected exception is like <em>OptirmisticException</em>.
     I have searched but no information about it yet. If you could clarify me, I will be appricate. Here is a piece of code from controller. 
  Thanks All.</p>
  
  <pre><code>@RequestMapping(value="/edit/{id}", method = RequestMethod.POST) 
  public String postEdit(@PathVariable Long id , @ModelAttribute("category")Category formCategory){
  
      try {
          Category category = categoryService.findOneCategory(id);
          if(category!=null) {
              category.setCatName(formCategory.getCatName());
              categoryService.save(category);
          }
      } catch (Exception e) {
            LOGGER.debug("Error message  : "+e);
      } 
  
      return PAGE_DEFAULT;
  }
  </code></pre>