Outer join fetch sends unnecessary SELECT to database to get parent

Description

In a bi-directional parent-children relationship, if I call session.Find() to outer join fetch like this
IList lst = session.Find("from Parent p left outer join fetch p.Children");
I saw a SELECT...FROM Parent LEFT OUTER JOIN Children to fetch both parent object and child objects, but after it there is a SELECT...FROM Parent WHERE... to get children's parent from database. The second SQL is really not necessary since the parent has been in memory after the 1st SQL.

I don't know if the 2nd level cache can avoid the 2nd SELECT hitting database any way.

Environment

None

Attachments

1

Activity

Ruurd Boeke December 30, 2005 at 7:31 AM

[do not know how to delete my attachment]

The issue I was having is slightly different then this issue.
I have created a new Jira for it https://nhibernate.jira.com/browse/NH-517 and attached a unit test to it for reproduction.

Ruurd Boeke December 16, 2005 at 5:51 AM

I have attached the mapping files, the select that I do and the selects that I think are unnecessary.

I hope that is what you need. If you need a project file, I will create that, but I'm hoping you have many relations around.

Former user December 16, 2005 at 3:50 AM

Can somebody please attach a simple test case showing the problem?

Ruurd Boeke December 16, 2005 at 3:43 AM

I too have seen this, and it really adds up.

Incomplete

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created October 27, 2005 at 2:39 PM
Updated April 19, 2008 at 4:01 PM
Resolved November 13, 2006 at 5:02 AM
Who's Looking?