且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用NHibernate Linq查询自引用联接

更新时间:2023-02-03 07:54:02

我的第一个反应是:是的-是这样的.不做任何事情,NHibernate总是尝试加载整个元素-这意味着它也加载了父元素.这真的是性能问题还是仅仅是美学问题? 而且我认为添加父ID不会对您有所帮助-因为它仍然会加载父项.

My first reaction would've been: yes - this is the way it is. Without doing anything NHibernate always tries to load the whole element - and this means that it loads the parent element too. Is this really a performance problem or is it just an aesthetical problem ? And I don't think that including the parent id would help you - because it still would load the parent item with it.

但是,如果您真的想优化此内容,请阅读以下文章 http://www.javalobby.org/java/forums/t20533.html .它是关于Hibernate的,但是它为您提供了有关如何处理此问题的一些想法以及针对您的问题的(可能的)解决方案.

But if you would really like to optimize this read the following article http://www.javalobby.org/java/forums/t20533.html. It is about Hibernate, but it gives you some ideas about how to handle this and a (possible) solution for your problem.