nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

Support Dynamic BatchFetchStyle

Open bahusoid opened this issue 3 years ago • 1 comments

Fixes #1316 Port of https://github.com/hibernate/hibernate-orm/commit/06b0faaf5770da47681d9d32e06ea204519a3846 (without Padded fetch style)

To start using Dynamic batch style add the following property to session-factory settings:

<property name="batch_fetch_style">Dynamic</property>

Or configuration by code:

Configuration configuration = ...
configuration.SetProperty(Environment.BatchFetchStyle, BatchFetchStyle.Dynamic.ToString());

bahusoid avatar Dec 16 '21 12:12 bahusoid

Please don't review while it's WIP. It's in working state AFAIK but not polished and no dedicated tests

bahusoid avatar Dec 16 '21 21:12 bahusoid

@bahusoid @hazzik For dynamic batch fetch style works correctly does default_batch_fetch_size needs to be bigger than 1, if it is than is it cause to dublicate queries in memory for those with 2 and 1 parameters.

property in (p0:,p1) property in (p0)

public virtual IUniqueEntityLoader BuildLoader(IOuterJoinLoadable persister, int batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters)
{
	if (batchSize <= 1)
	{
		// no batching
		return new EntityLoader(persister, lockMode, factory, enabledFilters);
	}

	return BuildBatchingLoader(persister, batchSize, lockMode, factory, enabledFilters);
}

gokhanabatay avatar Oct 04 '22 09:10 gokhanabatay