kpr284 wrote:
Hello bertrand,
Thank you for ur sugession on my query . The solution u gave for testing is very good and also easy but I need to write a test case for that is it possilble if so plz tell me what to do
What do wanna test? The fact that Hibernates throws the OptimisticLock exception in such case? If so, then you are writing a test case against Hibernate... which is not your job - you should rather test your application...
If you wanna test how your application behaves in such circumstances, then simply think about what will cause it to happen, and find a way to reproduce it in your test case!
Some hint:
- two threads accessing and modifying the data;
- to Hibernate sessions - one per thread of course;
- synchronization between the two so the first commits after the second;