• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Modification to readLock example in chapter 12 of JPA Pro

 
Ranch Hand
Posts: 1738
12
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, for everyone's reference, I modified readLock example of chapter 12 to demonstrate the fact that an optimistic lock can prevent an entity from being updated when it is being read from DB:


When the generateDepartmentSalaryReport method is called, I got this expected error:


Warning: A system exception occurred during an invocation on EJB EmployeeService, method: public examples.model.SalaryReport examples.stateless.EmployeeService.generateDepartmentsSalaryReport(java.util.List)
2017-02-17T21:00:43.818-0500|Warning: javax.ejb.EJBException  ...
Caused by: java.util.ConcurrentModificationException
at java.util.Vector$Itr.checkForComodification(Vector.java:1184)

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!