Error with filters on joined-subclass as one-to-one
Description
We have following entities:
Customer, which has deleted property
IndividualCustomer, which is inherited from Customer and has one-to-one (mapped as many-to-one with unique=true) relation to Person
Person which has IndividualCustomer property as one-to-one with property-ref to IndividualCustomer's Person property
If we enable filter, which filters deleted customers by deleted property and get person with criteria, following SQL is generated: SELECT ... FROM Person this_ left outer join IndividualCustomer individual2_ on this_.Id = individual2_.PersonID and individual2_1_.Deleted = 1 left outer join Customer individual2_1_ on individual2_.IndividualCustomerID = individual2_1_.Id
This obviously fails because the "filtering condition" (individual2_1_.Deleted = 1) is in wrong join.
Note that NH2049.zip uses a criteria query, while NH2049-NHib-3.2RC1.zip uses HQL. Both fail. Combined and slightly reworked test cases, still failing, added to 3.4.x branch in 7240908de2ab17dbf44b46f1c69919f4d6c11682.
C February 15, 2013 at 11:42 PM
Still happens in NHibernate 4 master.
Brian J. Sayatovic November 10, 2011 at 9:47 PM
Does anyone have a patch for this? I'd be willing to try it. This bug is stopping us from inserting data.
M. Uld July 28, 2011 at 12:08 PM
Still happen in Hibernate 3.2.0.3001. Attaching a NHibernate 3.2 test fixture with a simplier exemple to reproduce.
We have following entities:
Customer, which has deleted property
IndividualCustomer, which is inherited from Customer and has one-to-one (mapped as many-to-one with unique=true) relation to Person
Person which has IndividualCustomer property as one-to-one with property-ref to IndividualCustomer's Person property
If we enable filter, which filters deleted customers by deleted property and get person with criteria, following SQL is generated:
SELECT ...
FROM Person this_
left outer join IndividualCustomer individual2_ on this_.Id = individual2_.PersonID and individual2_1_.Deleted = 1
left outer join Customer individual2_1_ on individual2_.IndividualCustomerID = individual2_1_.Id
This obviously fails because the "filtering condition" (individual2_1_.Deleted = 1) is in wrong join.