Skip to content

Conversation

@bahusoid
Copy link
Member

@bahusoid bahusoid commented Dec 16, 2021

Fixes #1316
Port of hibernate/hibernate-orm@06b0faa (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());

Copy link
Member

@hazzik hazzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix formatting issues identified by codefactor and by me.

@bahusoid
Copy link
Member Author

bahusoid commented Dec 16, 2021

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

Assert.That(result.Name, Is.Not.Null);

var childrenCount = result.Children.Count;
//Assert.That(NHibernateUtil.IsInitialized(proxy), Is.True);
Copy link
Member Author

@bahusoid bahusoid Dec 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entity is already loaded by batch loading. But proxy doesn't know about it - NHibernateUtil.IsInitialized(proxy) returns false. Looks like an issue to me (not related to this PR)

@bahusoid bahusoid changed the title WIP Support Dynamic BatchFetchStyle Support Dynamic BatchFetchStyle Dec 17, 2021
@gokhanabatay
Copy link
Contributor

@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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NH-3530 - memory when using default_batch_fetch_size

4 participants