I am in the same situation. The problem with not-found = ignore is that it will require a relationship every time you try to access it, even if it was already running in the original request. In principle, sleep mode does not preserve the fact that there is no record for the other side of the relationship. This can be seen in the debug log. Here is an example from my current project.
loading entity: attempting to resolve: object not resolved in any cache: Fetching entity: loading entity: Opened new IDbCommand, open IDbCommands: 1 Building an IDbCommand object for the SqlString: SELECT townshipdo0_.TOWNSHIP_CODE as TOWNSHIP1_203_0_, townshipdo0_.TOWNSHIP_NAME as TOWNSHIP2_203_0_, townshipdo0_.TOWNSHIP_TYPE_CODE as TOWNSHIP3_203_0_, townshipdo0_.TOWN_ACTIVE_FLAG as TOWN4_203_0_, townshipdo0_.VERS as VERS203_0_ FROM VTTOW_TOWN_CODE townshipdo0_ WHERE townshipdo0_.TOWNSHIP_CODE=? binding ' ' to parameter: 0 SELECT townshipdo0_.TOWNSHIP_CODE as TOWNSHIP1_203_0_, townshipdo0_.TOWNSHIP_NAME as TOWNSHIP2_203_0_, townshipdo0_.TOWNSHIP_TYPE_CODE as TOWNSHIP3_203_0_, townshipdo0_.TOWN_ACTIVE_FLAG as TOWN4_203_0_, townshipdo0_.VERS as VERS203_0_ FROM VTTOW_TOWN_CODE townshipdo0_ WHERE townshipdo0_.TOWNSHIP_CODE=:p0
You can see that it is trying to bind, '' the database for this application uses empty space to represent null (dumb I know). But every time nhibernate encounters this, he will try to find it from the database, because he cannot find the entry in the cache and does not know that it is actually NULL.
It would be nice if we could specify a default value to ignore in the configuration. Currently, the only way around this is to use requests to load your relationships, rather than relying on the requests requested by nhibernate.
source share