Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Modification to readLock example in chapter 12 of JPA Pro

Ranch Foreman
Posts: 1897
  • 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(

Alas, poor Yorick, he knew this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic