Skip to content

NH-2888 - Add support to ICriteria to eager fetch lazy properties #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

stuartcarnie
Copy link
Contributor

Enables control for eager fetching of lazy properties for the root entity, one-to-one and many-to-one associations when using ICriteria queries. The new API is as follows:

ICriteria.SetLazyPropertyFetchMode(LazyPropertyFetchMode mode)
This affects the current ICriteria instance

ICriteria.SetLazyPropertyFetchMode(string associationPath, LazyPropertyFetchMode mode)
This affects the lazy loading of the specified associationPath (typically a one-to-one).

where mode is either

  • Default : Standard behaviour to lazy load properties
  • Select : Eager fetch as part of the initial select (using naming conventions from other enums)

I chose an enum, as it allows more flexibility in expanding the features later, such as a SelectAll to eager fetch all one-to-one's that are not lazy loaded.

Unit tests have been created to verify behaviour under NH-2888.

@oskarb
Copy link
Member

oskarb commented Feb 5, 2012

Large patch...

@@ -1005,5 +1037,16 @@ public System.Type GetRootEntityTypeIfAvailable()
return persistentClass;
throw new HibernateException("Cannot provide root entity type because this criteria was initialized with an entity name.");
}

public LazyPropertyFetchMode GetFetchAllProperties(string path)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this should be GetLazyPropertyFetchMode(path) for consistency.

@techniq
Copy link

techniq commented Jan 25, 2013

Would this also support the QueryOver API?

@hazzik hazzik changed the title FIX NH-2888: Add support to ICriteria to eager fetch lazy properties NH-2888 - Add support to ICriteria to eager fetch lazy properties May 7, 2014
@hazzik
Copy link
Member

hazzik commented May 7, 2014

Opened new pr #264

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.

4 participants