I have a scenario where I want to invalidate write operation. Briefing the scenario below:
There are two process running in altogether different systems and we have one common database. Let the process be termed as 'P1' and 'P2'. Each process can do read (R) and write (W) operaion. R1 and W1 show operation done by P1 and R2, W2 by P2. Lets take a common DB object (O).
Now operations are executing in following sequence :
R1 (read 'O' by process 'P1')
R2 (read 'O' by process 'P2')
W1 (write 'O' by process 'P1') -> this make 'O' of P2 dirty.
Now what I want is to fail P2 while performing its W2 operation as it contain old inconsistent object.
I have read few blogs of checking timestamp before persisting, but this is not the solution (as it is error prone even if it is matter of millisecs).
I want to know enterprise level solution.
Also I will like to know how it can be achieved by using 3rd party solution like hibernate.