I don't think that it is a one-to-one relation. one-to-one relation in the database is only achieved by synchronizing primary keys. You actually can omit an additional foreign key. In this case, you have a foreign key in address, customerId, so it is a regular many-to-one.
The N+1 problem is something different. It depends if you mapped the addresses as separate properties or as a dictionary. When using a dictionary, it would us a single query to get all addresses of a customer. When using batch-size, it would get them all at once. When using single properties, it should work to get them by joining. I actually had bad experience with joins. In complex cases the queries got too big and the database wasn't able to execute it. In this simple case, it may work fine. If you have any problems with the joins, you could also use batch-size to optimize the N+1 problem. I'm not sure about it, but it could be that NH batches only the same property for several customers at once. You need to try. On 4 Nov., 04:09, Joseph Daigle <[email protected]> wrote: > Some additional info: you find the exact same behavior if you change > the one-to-one mappings to one-to-many mappings. > > It seems that NHibernate will only do 1 left outer join per mapping > type per concrete table. > > On Nov 3, 10:56 pm, Joseph Daigle <[email protected]> wrote: > > > So basically if I have N subclasses, when I load Customer it always > > results in 1 + N - 1queries. The first is a join of Customer and the > > first subclass, the rest are just the subclass fetches. > > -- 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.
