In hibernate docs we can read that hibernate.default_batch_fetch_size should be 4,8,16
but I discovered strange behavior
when I load entity by session.load(Person.class, id) and hibernate has another ids in cache then generates query: select from where id IN(?,?,?) which is correct
by when I call session.load(Person.class, id, LockMode.PESSIMISTIC) then generates also query:
select from where id IN(?,?,?) for update which is incorrect and lead sometimes to deadlock in production
thanks for the test case!
Even in org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(LockMode, LoadQueryInfluencers) there is comment about it