I am opening this bug after working more than one week on the problem.
Here is the story ...
I started development with Hibernate 2.1 for a specific application for a customer. I have never
seen this problem during the development phase. While I was doing the training users to test the application
I got a "org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [hibernate.test.Record#3096] ...".
I was working (adding/updating) on data while they was looking at the work I did using the application.
And of course it is the first objective of the application to share informations between users ....
I suspected a cache problem and I have searched throught Jira for a similar problem. I saw a bug (HHH-821) that
solve a problem in the first level cache which is fixed after 3.0.5.
I then evaluate migrating to 3.1RC1 and miracle 3.1 was officialy released the same day !
We worked on migration and many things had to be reworked but we have managed this.
Finally we tested again the application and ..... the same problem occurs.
I finally decided to write a small test bed to check if Hibernate was able to support concurrent connection
and it seems there is a problem in concurrent access (maybe I can be wrong).
I wrote a small class, throwing 10 thread.
Each thread, after a random sleep, ask the Main class what to do ? Add, update or delete a record. The
Main class give him the record and the action. When work is performed by the thread, the Main class
is called again to update its internal table of what MUST be in the database (and after verification it is
really what's in the database).
When the thread has accomplished the action, he then asks the main class 5 record to check (for existance and content
with a Session.load). And I can reproce the phenomenon.
I have attached the needed files to run this test and a log of the printout.
Have a look in the log to record with ID 3096. Thread 3 can't read it and generates
an exception while thread 4 read it safely ! (Since it is multithreaded, lines are mixed but the line
"[Thread 3] *************" is the beginning of the stack trace of the exception.
Any idea ?
If I can be in any help, don't hesitate to contact me.
Indeed it is a great work !
Hibernate V 3.1, JDK 1.4.2_08