On Sep 26, 4:44 pm, "Jon Palmer" <[EMAIL PROTECTED]> wrote:
> There are two things going on in your scenario
>
> 1. Returning the correct type of mapped object
> 2. Filtering the rows due to legacy data.
>
> Returning the correct type of mapped object
> In The case that there is only one class NHibernate assumes every row in
> the table is of that class. It has no need to add the address_type_code
> to the select because it's going to build Addresses regardless of the
> value. It would be very strange (and I suspect broken) to expect
> Nhibernate to query for the rows and then only hydrate into Addresses
> those entries that matched the discriminator. In that situation the row
> Count of the sql query would could be different than the count of actual
> objects returned after hydration. Yuck.

I agree that it would return far more rows than needed, which isn't
ideal from a performance perspective. If we ignore performance for a
minute and think about it from a polymorphic query perspective, it
makes much more sense to always include the discriminator column in
the select statement.

the reason for doing this is flexibility, which is always going to
trade off performance, so it's not like we're blindly doing this. It's
also why I mentioned views as a work around. If performance is an
issue, I prefer to create a materialized view and map the class to it.

I don't know about other people, but in a situation where you want to
provide a base set of functionality and allow end users create custom
extensions, this approach may be a good solution. Of course, one could
argue the base class can use "where" clause, but then it wouldn't work
as nicely for polymorphic queries.  NHibernate would end up making
multiple queries, instead of making 1 query and create the correct
instances.

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