在运行时更改为延迟加载

时间:2023-01-15 22:47:04

I'm using nhibernate to load parent class in a not lazy way and I have many-to-many set of child class that I want to determine in run time rather to load it lazy or not. I'm using .hbm.xml mapping and I tried to change the set "lazy" property after loading the assemblies, is it possible?

我正在使用nhibernate以非懒惰的方式加载父类,并且我有多对多的子类,我想在运行时确定它而不是加载它是否懒惰。我正在使用.hbm.xml映射,我试图在加载程序集后更改set“lazy”属性,是否可能?

1 个解决方案

#1


I think the best (only) way is to set lazy=false and then in your HQL use "join fetch" or in criterias use SetFetchMode on a collection that needs to be eagerly retrieved.

我认为最好的(唯一的)方法是设置lazy = false然后在你的HQL中使用“join fetch”或者在标准中使用SetFetchMode对需要急切检索的集合。

Read more here: http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx

在这里阅读更多内容:http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx

/Asger

#1


I think the best (only) way is to set lazy=false and then in your HQL use "join fetch" or in criterias use SetFetchMode on a collection that needs to be eagerly retrieved.

我认为最好的(唯一的)方法是设置lazy = false然后在你的HQL中使用“join fetch”或者在标准中使用SetFetchMode对需要急切检索的集合。

Read more here: http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx

在这里阅读更多内容:http://ayende.com/Blog/archive/2006/05/02/CombatingTheSelectN1ProblemInNHibernate.aspx

/Asger