aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes My acrobatics for data integrity. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "My acrobatics for data integrity." Watch "My acrobatics for data integrity." New topic
Author

My acrobatics for data integrity.

Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Hi, guys! Again I trouble the forum with some tid bit of locking information. I implemented the find method in the Data class, but the business method, findRoom, could not guarantee that in a multi-threading environment, the records returned would be accurate. So the solution? Check the record for fulfilling the criteria twice! I am not kidding, alas, I am checking it twice, and the code is almost the same. The first time my find method checks it, and the second, my findRoom method checks it. What do you guys think? Is it somehow extra work, did I go into unnecessary complexity here, or is it right?

(Or maybe it could be the elegant solution, and the second, business-code check could at the same time fulfill the requirement of sending only complete matches to the client???)

Thanks for everyone's opinion!
[ September 14, 2004: Message edited by: Anton Golovin ]

Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Anton Golovin:
Hi, guys! Again I trouble the forum with some tid bit of locking information. I implemented the find method in the Data class, but the business method, findRoom, could not guarantee that in a multi-threading environment, the records returned would be accurate. So the solution? Check the record for fulfilling the criteria twice! I am not kidding, alas, I am checking it twice, and the code is almost the same. The first time my find method checks it, and the second, my findRoom method checks it. What do you guys think? Is it somehow extra work, did I go into unnecessary complexity here, or is it right?

(Or maybe it could be the elegant solution, and the second, business-code check could at the same time fulfill the requirement of sending only complete matches to the client???)

Thanks for everyone's opinion!

[ September 14, 2004: Message edited by: Anton Golovin ]


The database and business rules for find are different, so you probably do need to do a second filtering. There is a trick to provide the exact match, append a '\0' to the end of the search text, it will only match exactly. You also might need to process the OR condition and you need to check that the data hasn't been changed or deleted between your search and your retrieve. you also might want to sort the result.
 
jQuery in Action, 2nd edition
 
subject: My acrobatics for data integrity.
 
Similar Threads
find method signature and synchronized.
Handling Null & Empty String in your Tranfer Object
Page Navigaion issue
Locking confusion -- help
name and/or location search