Hi
I using 0.9.0.0 build of NHibernate and I'm getting the following error when attempting to retrieve a list of 'File' type objects. The subclassed, 'Image', type objects are in contast retrieved correctly.
Here's my mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="HardBopRecords.Models.Files.File,HardBopRecords.Models"
table="`File`"
discriminator-value="Unknown">
<meta attribute="class-description"></meta>
<jcs-cache usage="read-write"/>
<id name="_FileId" column="FileId" type="Guid" unsaved-value="{00000000-0000-0000-0000-000000000000}">
<meta attribute="field-description"></meta>
<generator class="guid.comb"/>
</id>
<discriminator column="Type" />
<property name="_Name" column="Name" type="String" length="255">
<meta attribute="field-description"></meta>
</property>
<property name="_Description" column="Description" type="String" length="512">
<meta attribute="field-description"></meta>
</property>
<property name="_Size" column="Size" type="Int32">
<meta attribute="field-description"></meta>
</property>
<property name="_Path" column="Path" type="String" length="1024">
<meta attribute="field-description"></meta>
</property>
<many-to-one name="_FileCategory" class="HardBopRecords.Models.FileCategorys.FileCategory,HardBopRecords.Models" column="FileCategoryId" />
<subclass name="HardBopRecords.Models.Images.Image,HardBopRecords.Models" discriminator-value="Image"/>
</class>
</hibernate-mapping>
I profiled the generated sql and noticed that the sql is correct for the subclassed, Image, type in that I get the following:
Code:
SELECT this.FileId as FileId1_, this.Size as Size1_, this.Name as Name1_, this.Description as Descript4_1_, this.Path as Path1_, this.FileCategoryId as FileCate7_1_, filecate1_.FileCategoryId as FileCate1_0_, filecate1_.Name as Name0_, filecate1_.Description as Descript3_0_, filecate1_.CanBeDeleted as CanBeDel4_0_ FROM [File] this left outer join [FileCategory] filecate1_ on this.FileCategoryId=filecate1_.FileCategoryId WHERE 1=1 and this.Type='Image'
notice the ...and this.Type='Image' on the end
However, the other type, File, results in the following sql:
Code:
select top 10 this.fileid as fileid1_, this.type as type1_, this.size as size1_, this.name as name1_, this.description as descript4_1_, this.path as path1_, this.filecategoryid as filecate7_1_, filecate1_.filecategoryid as filecate1_0_, filecate1_.name as name0_, filecate1_.description as descript3_0_, filecate1_.canbedeleted as canbedel4_0_ from [file] this left outer join [filecategory] filecate1_ on this.filecategoryid=filecate1_.filecategoryid where 1=1
notice the absence of the descrimintor where clause.
I am doing something wrong, or is this a bug, anyone have any ideas?
Thanks