Hi,
I am a newbie to Hibernate here is my problem
1. I created a java utility, which runs 5 threads Simultaneously,
2. Each thread call a synchronized method which thread fetches a Single record whose status is free (for getting the single record based on status of that record. I am opening the session explicitly and starting transaction & creating a Query object then passing the int value in setMaxResults method of query).
3. It returns the list containing that single record, then I change in status of record to busy, to mark that a thread it working on it (for doing this I am using getHibernateTemplate.update method)
4. Then I work with that record.
5. In last I change the status to done to mark that I am finished with the record.
I am facing problem in step 2 and 3
while viewing logs i come to know that once I thread changes the status of the record to busy even then other threads are able to access it and they start processing it again which should not happen.
Any suggestions which can help me to know where I am wrong
Thanks & regards
|