You don't need to get into filters to support the legacy data base with data 
you don't want use the where clause in the mapping. So instead of this:

 

 

<class name="Address" table="Addresses" discriminator-value="myAddress" >

<id name="ID" column="ID" type="integer" >

              <generator class="identity"/>

       </id>

       <discriminator column="AddressType" type="string"/>

       ........

</class>

 

 

You do this:

 

 

<class name="Address" table="Addresses" where="AddressType = 'myAddress'" >

<id name="ID" column="ID" type="integer">

              <generator class="identity"/>

       </id>

       ........

</class>

 

 

Jon

 

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Tuna 
Toksöz
Sent: Friday, September 26, 2008 11:43 AM
To: [email protected]
Subject: [nhusers] Re: Discriminator bug

 

http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/filters.html

On Fri, Sep 26, 2008 at 9:40 PM, Tuna Toksöz <[EMAIL PROTECTED]> wrote:

I think this is where filters come into play?

 

On Fri, Sep 26, 2008 at 9:31 PM, Jon Palmer <[EMAIL PROTECTED]> wrote:


Can't you just specify a Where clause in the definition of the single
class mapping.



-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Peter Lin
Sent: Friday, September 26, 2008 11:29 AM
To: nhusers
Subject: [nhusers] Re: Discriminator bug



the reason is simple. what if I'm reading data from an existing
database, which uses the concept of a discriminator with
address_type_code. what if the address table has entries with
different address_type_code values?

If I only want to get a specific type of address from the database and
I don't have a subclass, NHibernate wouldn't return the correct
result. It would return all rows, instead of just the rows with the
specific address_type_code.

I just looked at the release notes for NH 2.0 and it looks like this
scenario is supported.

Added [ Table per subclass, using a discriminator ] Support to
Nhibernate

http://ayende.com/Blog/archive/2008/03/31/NHibernate-2.0-Alpha-is-out.as
px

unfortunately, I can't upgrade to NH 2.0. I understand NH might not
consider this a valid use case, but I definitely consider it a valid
use case.

peter

On Sep 26, 11:20 am, "Fabio Maulo" <[EMAIL PROTECTED]> wrote:
> Why you think that it is a bug ?If a class don't have a <subclass>
(mean you
> have only one value for discriminator and that mean don't have nothing
to
> discriminate), why NH must add the discriminator clause ?
>
> 2008/9/26 Peter Lin <[EMAIL PROTECTED]>
>
>








-- 
Tuna Toksöz

Typos included to enhance the readers attention!




-- 
Tuna Toksöz

Typos included to enhance the readers attention!




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