Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

Modification to readLock example in chapter 12 of JPA Pro

Ranch Hand
Posts: 1749
  • 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(

it's a teeny, tiny, wafer thin ad:
Enterprise-grade Excel API for Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!