• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

synchronizing findByCriteria() and readRecord() methods?

 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My question concerns concurrency and the two methods, findByCriteria() and readRecord(). There is a time lag between "finding" a list of records that meet a set of criteria and "reading" those same records from the database. My implementation of the Data class doesn't use locking/unlocking with the findByCriteria() method, nor does it use locking/unlocking with the readRecord() method. First, findByCriteria() returns a list of records that meet the search criteria, and then, I must use the readRecord() method to read that list of records into my JTable. This is not an atomic operation. Other clients can access the "found" records in the list before I read them from the database file, and these clients can modify/delete records on my list of "found" records.

How did you handle this problem?

Thanks,
Harry
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harry,

There are so many threads regarding this issue already in this forum that you certainly can find several of them using the search function. This one is just a few weeks old (take a look at my last post in that thread).

Kind regards,
Roel
 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

The answer to my question is actually pretty simple. I don't think that this implementation can deadlock at the Business Layer.


Best Regards,

Harry
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harry,

That is the 2nd operation I described (the atomic operation), so indeed that should do the job without any deadlock (or RNFE being thrown )

Small remark: the "new Long(recNo)" (line 7) is not needed, you simply can use "recNo" instead (thanks to Java 5 feature boxing)

Kind regards,
Roel
 
I once met a man from Nantucket. He had a tiny ad
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic