add pessimistic/optimistic lock for hibernate