At the beginning I suspected that working with 2nd-level cache might cause us problems: data won't reflect immediately between 2 application, working against the same DB (Oracle 10g).
But than, after few tests, and re-thinking, the problem exists no matter what kind of caching method I use.
If I create new 2 elements, one from each application, at the same time - the same Id will be supplied to both new created element causing one of them to fail (pk/unique constraint violation).
Meaning, I need to change the Id generation mechanism from general "increment" to "sequence" or any other shared (on physical level) resource.
There is no way to enforce 2 session factories, with 2 sessions to considerate each other - only on DB level (which strongly not supported by Informix 10 sequence)
Am I right? Is that the right way to implement object creation by 2 applications?
Another question raised by the same issue is the consistency when updating the same elements from both applications: I saw an advice to use timestamp or version - could it help to check one object is not occupied by other application? (this case will rarely occur if at all - but it's still interesting)
Thanks a lot,
Moti
|