Select statement issued for each not-found=ignore

Description

When using the not-found=ignore attribute in a one-to-many/many-to-many, NHibernate is issuing a query for every element not found in the collection, even when using an outer join.

In some cases this causes a significant performance overhead.

Environment

None

Activity

Show:
Sÿl
March 29, 2012, 1:55 PM

Same here, just signed it to vote for this, issue. I'm using nhibernate 3.2 I'm mapping an odd db in which database is inconsistent.
Would be great if it could fixed soon

Taavi Kõosaar
May 4, 2012, 4:16 PM

A temporary workaround for guys with legacy database issues and cant fix the schema always (im in the same pain).
The Nullable Tuplizer approach works nicely, but needs some maintenance.

http://nhforge.org/blogs/nhibernate/archive/2011/01/28/how-to-use-0-instead-of-null-for-foreign-keys.aspx

Use that approach instead of not-found="ignore". In my case i maintain a list of bad reference cases such as where in database row value can be 0 or-1 to indicate that there is no reference (i.e. supposed to be NULL value in row).

Johan Haest
February 14, 2013, 11:41 AM

Taavi, this is true when you are lazy loading, but what if you are eagerly fetching the row? I can't get any work around for this. This is creating so many queries.

Mark Seefeldt
March 22, 2013, 5:04 PM

Posted a one-to-one scenario on SO. Hoping someone who knows a workaround has some ideas. http://stackoverflow.com/questions/15575378/mapping-an-extension-table-that-might-not-have-a-row

Alex Zaytsev
March 11, 2019, 8:31 AM

Moved here.

Fixed

Assignee

Alex Zaytsev

Reporter

Tomer Avissar

Components

Fix versions

Affects versions

Priority

Minor
Configure