The incredibly verbose mapping was generated by Castle ActiveRecord.

The reason there's no property under the joined-subclass
AllocatedSelection is that I'm trying to use the class of
AllocatedSelection as a discriminator that the Selection isn't a
CompletedSelection - that's why there are no extra properties.
Otherwise to find ones uncompleted I'd have to somehow query against
Selection where the class isn't CompletedSelection.  With this
subclass distinction I can query AllocatedSelection and
CompletedSelection separately very easily.  This may be the problem.

As far as the query, again I'm using Castle ActiveRecord so this is
simply me accessing a lazy collection on an InventoryContainer.  The
query generated is ~25k, but the pertinent part is the filter:

FROM AllocatedSelectionPart allocateds0_ inner join Selection
allocateds0_1_ on allocateds0_.ID=allocateds0_1_.ID
...
WHERE allocateds0_.source_inventorycontainer...@p0

And the Source_InventoryContainerID column does indeed exist on the
AllocatedSelectionPart table, but it shouldn't - it's a property of
the Selection class, not the AllocatedSelectionPart or
CompletedSelectionPart subclasses.  The query -should- read

FROM AllocatedSelectionPart allocateds0_ inner join Selection
allocateds0_1_ on allocateds0_.ID=allocateds0_1_.ID
...
WHERE allocateds0_1_.source_inventorycontainer...@p0

On Feb 19, 1:00 pm, Fabio Maulo <[email protected]> wrote:
> I cant find any extra column.Please send the HQL/Criteria and the generated
> SQL you are talking about.
>
> 2009/2/19 Jonathan <[email protected]>
>
>
>
>
>
>
>
> > 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
>
> --
> Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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