Thanks for your answer!
I chose your second approach, and did a deeper research (logging session) of the SELECT FOR UPDATE statement. I found out that on oracle side,
it is possible to set a parameter on tables/indexes called INITRANS.
I am not absolutley sure about it's meaning, so i don't try to explain it... :-)
I set the value of this parameter to 100 for all indexes in the table / and on the table itself --> I get (hardly) no deadlocks any more.
Hardly, because in did a few tests with 1000 bookings/5 threads --> 5000 bookings alltogether and got in one of them 2 deadlock errors... :-)
Current possible solution:
Code:
Criteria crit = session.createCriteria(Days.class)
.setLockMode(LockMode.UPGRADE)
.add(Restrictions.eq("hotel.id", new Integer (hotel.getId())))
.add(Restrictions.between("day",updatePeriod.getDateFrom(),
updatePeriod.getDateUntil()))
.addOrder(Order.asc("day"));
List list = crit.list();
Set Table and Index Initrans to 100:
Code:
ALTER TABLE DAY INITRANS 100;
ALTER INDEX DAY_PK INITRANS 100;
ALTER INDEX HOTEL_I INITRANS 100;
ALTER INDEX DAY_PK INITRANS 100;
Does anyone see a problem with this solution?