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

Modification to readLock example in chapter 12 of JPA Pro

 
Ranch Hand
Posts: 1749
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's a teeny, tiny, wafer thin ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!