Jose F. Romaniello, Thank you for quick response and explanation.

The problem is transaction_id = 0 has a meaning in the system. Fairly
hard to redesign it :(

Im looking into changing this, but this is not the only location :(

But there could be made a optimization. I remember there's a where
condition possibility? Would that help?

Taavi

On Sep 6, 4:20 pm, José F. Romaniello <[email protected]> wrote:
> Thats the way it works by design.
> An nhibernate need a guarantee that the reference exists, when using
> not-found="ignore", let me try to explain the why
>
> Contract.Transaction can have too values when working with lazy load,
>
>    - a nhibernate proxy if the other side of the relationship exists
>    - a null, if the relationship doesn't exists
>
> When the ForeingKeys work as expected, a null value in the TransactionId
> field, is represented by a null value in the Transaction property.
> So, when you said to nhibernate "not-found=ignore" nhibernate needs to check
> if the other side of the relationship (in the transaction table) exists.
> Maybe there is room to improvement, I saw few months ago, that nhibernate
> keep asking for the record 0, many times.... But I didn't have enough time
> to propose an improvement.
>
> I *strongly* recommend fix your data. You can insert a transaction with id =
> 0, "No transaction", or issue an update to convert all 0's to null.
>
> 2010/9/6 Melborp <[email protected]>
>
>
>
> > Hej,
>
> > No response? Is there no such known issue with not-found="ignore" ?
>
> > I know our database is a little unorthodox, but if there's any chance
> > of ORM to work with it, its probably NHibernate.
>
> > Im still having this issue.
>
> > Taavi
>
> > On Sep 1, 12:02 am, Melborp <[email protected]> wrote:
> > > Hej,
>
> > > I have a class called Contract and each Contract can have 0 or 1
> > > Transaction with it.
>
> > > Unfortunately i have a legacy database, where the transctionId in
> > > Contract table can have value NULL, 0 or a real Id referencing
> > > transaction. I cannot change the database.
>
> > > So i tried using NotFound.Ignore() instead. (not-found="ignore") This
> > > works nicely when i get 1 contract and when there's transaction, also
> > > get that.
> > > However i also have a page which lists a bunch of contracts and even
> > > though in code i never specify for it to load the Transaction (not
> > > lazyly or eagerly), i can see from NHibernate Profiler that whereever
> > > the value is 0 it seems to make a lazy load try to find the
> > > transaction for contract. This causes a lot of queries against the
> > > database.
> > > When i turn off not-found="ignore" the lazy loading works nicely (no
> > > queries are generated to try to get a transaction with Id 0), however
> > > this is not suitable because it will throw an expcetion whenever i try
> > > to access transction and it is not found (its neither null or valid
> > > association id).
>
> > > Is this a known problem with not-found="ignore" ? Any workaround?
> > > Ideas?
>
> > > Thanks,
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]­>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to