Please forgive me if my previous searching was inadequate, but I was unable to find any mention of this behavior on the list or issue tracker, so here goes. I'm having problems with a joined-subclass mapping in NHibernate 2.1.0.1001 generating duplicated columns on the subclass tables, then querying against them.
My mapping file is as follows: <?xml version="1.0" encoding="utf-16"?> <hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate- mapping-2.2"> <class name="Genesta.SyLogis3.Models.Selection, SyLogis3.Models" table="Selection"> <id name="ID" access="property" column="ID" type="Int64" unsaved- value="0"> <generator class="native"> </generator> </id> <property name="AllocatedTime" access="property" type="System.DateTime"> <column name="AllocatedTime" not-null="true"/> </property> <property name="Quantity" access="property" type="Int64"> <column name="Quantity" not-null="true"/> </property> <property name="Sequence" access="property" type="Int64"> <column name="Sequence" not-null="true"/> </property> <many-to-one name="DestinationLocation" access="property" class="Genesta.SyLogis3.Models.Location, SyLogis3.Models" column="Destination_LocationID" /> <many-to-one name="SourceContainer" access="property" class="Genesta.SyLogis3.Models.InventoryContainer, SyLogis3.Models" column="Source_InventoryContainerID" not-null="true" /> <many-to-one name="OrderQuantity" access="property" class="Genesta.SyLogis3.Models.OrderQuantity, SyLogis3.Models" column="OrderQuantityID" not-null="true" /> <joined-subclass name="Genesta.SyLogis3.Models.AllocatedSelection, SyLogis3.Models" table="AllocatedSelectionPart"> <key column="ID" /> </joined-subclass> <joined-subclass name="Genesta.SyLogis3.Models.CompletedSelection, SyLogis3.Models" table="CompletedSelectionPart"> <key column="ID" /> <property name="SelectedQuantity" access="property" type="Int64"> <column name="SelectedQuantity" not-null="true"/> </property> <property name="SelectedTime" access="property" type="System.DateTime"> <column name="SelectedTime" not-null="true"/> </property> <many-to-one name="DestinationContainer" access="property" class="Genesta.SyLogis3.Models.OrderContainer, SyLogis3.Models" column="Destination_OrderContainerID" not-null="true" /> <many-to-one name="SelectedSession" access="property" class="Genesta.SyLogis3.Models.SpeechSession, SyLogis3.Models" column="SpeechSessionID" not-null="true" /> </joined-subclass> </class> </hibernate-mapping> The generated creation script is as follows: create table Selection ( ID BIGINT IDENTITY NOT NULL, AllocatedTime DATETIME not null, Quantity BIGINT not null, Sequence BIGINT not null, Destination_LocationID BIGINT null, Source_InventoryContainerID BIGINT not null, OrderQuantityID BIGINT not null, primary key (ID) ) create table AllocatedSelectionPart ( ID BIGINT not null, Source_InventoryContainerID BIGINT null, primary key (ID) ) create table CompletedSelectionPart ( ID BIGINT not null, SelectedQuantity BIGINT not null, SelectedTime DATETIME not null, Destination_OrderContainerID BIGINT not null, SpeechSessionID BIGINT not null, Source_InventoryContainerID BIGINT null, primary key (ID) ) My intent is to use the AllocatedSelection subclass to be able to query specifically all non-CompletedSelections. The problem here is that the SourceContainer property (mapped to column Source_InventoryContainerID) is a property of the base Selection class, but is clearly present on both the AllocatedSelectionPart and CompletedSelectionPart tables. Upon storing an AllocatedSelection, the Selection table is updated with the correct property, but when querying against a collection of AllocatedSelection, the query attempts to filter on AllocatedSelectionPart.Source_InventoryContainerID instead of Selection.Source_InventoryContainerID (which is of course always null due to the previous behavior). Is this indeed a bug in NHibernate (I think so, due to the discrepancy between the mapping and the generated schema/queries), or am I doing something crazy and unsupported? Thanks, Jonathan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
