I have an EntityObject which is based on a db table that has a Unique
index defined on two of its attributes(say - id,code). I have a VO based
on this EO and it is used by "updatable table" in the UI.
I have a concurrent scenario like this
1.user1 enters and click on + button to create a new row
2.user2 enters and click on + button to create a new row
3.user1 enters the values
4.user2 enters values with id & code same as entered by user1
5.user1 clicks on save button
6.user2 clicks on save button
7.user1 save operations is success
8.user2 gets Application error due to an incident. Incident log says that it is due to violating the Unique index in the db and the exception is java.sql.SQLIntegrityConstraintViolationException
To handle this issue, I did the following
I created an AltKey in the EO on attributes id & code and then created an UniqueKey Validator on the AltKey. When tested, I noticed that I still get the incident same as in Step-8 in the above scenario. I suspect the Unique key Validator is only checking the cache and not the db.
If a user clicks + button twice and enters the same values in both the rows and then clicks on save button, the unique key validator seems to be working but not in the multi-user/concurrent scenario i mentioned above.
Then I tried setting EntityLevelOnly="true" for the unique key validator from property inspector and it worked.
I have a concurrent scenario like this
1.user1 enters and click on + button to create a new row
2.user2 enters and click on + button to create a new row
3.user1 enters the values
4.user2 enters values with id & code same as entered by user1
5.user1 clicks on save button
6.user2 clicks on save button
7.user1 save operations is success
8.user2 gets Application error due to an incident. Incident log says that it is due to violating the Unique index in the db and the exception is java.sql.SQLIntegrityConstraintViolationException
To handle this issue, I did the following
I created an AltKey in the EO on attributes id & code and then created an UniqueKey Validator on the AltKey. When tested, I noticed that I still get the incident same as in Step-8 in the above scenario. I suspect the Unique key Validator is only checking the cache and not the db.
If a user clicks + button twice and enters the same values in both the rows and then clicks on save button, the unique key validator seems to be working but not in the multi-user/concurrent scenario i mentioned above.
Then I tried setting EntityLevelOnly="true" for the unique key validator from property inspector and it worked.