I've got a fairly simple table schema:

[Customer]
CustomerId int NOT NULL
Name varchar NOT NULL

[Address]
AddressId int NOT NULL
CustomerId int NOT NULL
AddressType int NOT NULL
Address varchar NOT NULL

The [Address] table is constrained such that CustomerId and
AddressType make up a unique key. AddressId is the primary key, but
not really relevant. The idea is that a customer can have 0 or 1
address for each address type, and each Address must belong to unique
Customer.

My domain model consists of

1. a Customer class
2. an abstract Address class
3. subclasses of Address for each address "type"

The Customer class has a one-to-one reference to each Address
subclass. The abstract Address class has a reference back to the
Customer.

Everything /works/ pretty awesomely. NHibernate is smart enough to add
the AddressType criteria when resolving the subclassed one-to-one
reference. When I load a Customer it loads each of my Address
subclasses as expected since it's mapped one-to-one. HOWEVER despite
the fact that each is mapped with fetch="join", only the FIRST one-to-
one is actually fetched with a left outer join. The remaining are
fetched via a separate select statement.

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.

Any thoughts?

-- 
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