Really? The HQL seems to have allocated values to the different subclasses using a case statement, so it must have some idea of what each class represents.
The only issue here is that when the type name is included in the HQL statment (alias.class = fully_qualified.typename) the generated SQL has not coverted the typename to the value that matches the other values allocated in the SQL case statement.
For example, the HQL statement...
Code:
FROM InputProfile p WHERE p.class = Framework.FtpInputProfile
...produces the following SQL:
Code:
select inputprofi0_.InputProfileID as InputPro1_, case when [inputprofi0__1_].FtpInputProfileID is not null then 1 when [inputprofi0__2_].CftInputProfileID is not null then 2 when [inputprofi0__3_].SmtpInputProfileID is not null then 3 when [inputprofi0__4_].WebsiteInputProfileID is not null then 4 when [inputprofi0__5_].OcrInputProfileID is not null then 5 when inputprofi0_.InputProfileID is not null then 0 end as clazz_, inputprofi0_.Version as Version19_, inputprofi0_.Deleted as Deleted19_, inputprofi0_.Created as Created19_, inputprofi0_.InputInterface as Input6_19_, inputprofi0_.ParentUserID as Paren7_19_, inputprofi0_.Modified as Modif4_19_, [inputprofi0__1_].AutoForward as AutoF2_20_, [inputprofi0__1_].AutoForwardHost as AutoF3_20_, [inputprofi0__1_].AutoForwardPort as AutoF4_20_, [inputprofi0__1_].AutoForwardUsername as AutoF5_20_, [inputprofi0__1_].AutoForwardPassword as AutoF6_20_, [inputprofi0__1_].WelcomeMessage as Welco7_20_, [inputprofi0__1_].StoragePath as Stora8_20_, [inputprofi0__5_].ImmediateInject as Immed2_30_, [inputprofi0__5_].ConfirmationFax as Confi3_30_, [inputprofi0__5_].AlertFax as Alert4_30_, [inputprofi0__5_].IMediaProductionAccountID as IMedi5_30_, [inputprofi0__5_].ConfirmationTemplateDocID as Confi6_30_, [inputprofi0__5_].AlertTemplateDocID as Alert7_30_ from Framework.dbo.InputProfiles inputprofi0_ left outer join Framework.dbo.FtpInputProfiles [inputprofi0__1_] on inputprofi0_.InputProfileID=[inputprofi0__1_].FtpInputProfileID left outer join Framework.dbo.CftInputProfiles [inputprofi0__2_] on inputprofi0_.InputProfileID=[inputprofi0__2_].CftInputProfileID left outer join Framework.dbo.SmtpInputProfiles [inputprofi0__3_] on inputprofi0_.InputProfileID=[inputprofi0__3_].SmtpInputProfileID left outer join Framework.dbo.WebsiteInputProfiles [inputprofi0__4_] on inputprofi0_.InputProfileID=[inputprofi0__4_].WebsiteInputProfileID left outer join Framework.dbo.OcrInputProfiles [inputprofi0__5_] on inputprofi0_.InputProfileID=[inputprofi0__5_].OcrInputProfileID where (case when [inputprofi0__1_].FtpInputProfileID is not null then 1 when [inputprofi0__2_].CftInputProfileID is not null then 2 when [inputprofi0__3_].SmtpInputProfileID is not null then 3 when [inputprofi0__4_].WebsiteInputProfileID is not null then 4 when [inputprofi0__5_].OcrInputProfileID is not null then 5 when inputprofi0_.InputProfileID is not null then 0 end=0)
and the HQL...
Code:
FROM InputProfile p WHERE p.class = Framework.SmtpInputProfile
...produces the following SQL:
Code:
select inputprofi0_.InputProfileID as InputPro1_, case when [inputprofi0__1_].FtpInputProfileID is not null then 1 when [inputprofi0__2_].CftInputProfileID is not null then 2 when [inputprofi0__3_].SmtpInputProfileID is not null then 3 when [inputprofi0__4_].WebsiteInputProfileID is not null then 4 when [inputprofi0__5_].OcrInputProfileID is not null then 5 when inputprofi0_.InputProfileID is not null then 0 end as clazz_, inputprofi0_.Version as Version19_, inputprofi0_.Deleted as Deleted19_, inputprofi0_.Created as Created19_, inputprofi0_.InputInterface as Input6_19_, inputprofi0_.ParentUserID as Paren7_19_, inputprofi0_.Modified as Modif4_19_, [inputprofi0__1_].AutoForward as AutoF2_20_, [inputprofi0__1_].AutoForwardHost as AutoF3_20_, [inputprofi0__1_].AutoForwardPort as AutoF4_20_, [inputprofi0__1_].AutoForwardUsername as AutoF5_20_, [inputprofi0__1_].AutoForwardPassword as AutoF6_20_, [inputprofi0__1_].WelcomeMessage as Welco7_20_, [inputprofi0__1_].StoragePath as Stora8_20_, [inputprofi0__5_].ImmediateInject as Immed2_30_, [inputprofi0__5_].ConfirmationFax as Confi3_30_, [inputprofi0__5_].AlertFax as Alert4_30_, [inputprofi0__5_].IMediaProductionAccountID as IMedi5_30_, [inputprofi0__5_].ConfirmationTemplateDocID as Confi6_30_, [inputprofi0__5_].AlertTemplateDocID as Alert7_30_ from Framework.dbo.InputProfiles inputprofi0_ left outer join Framework.dbo.FtpInputProfiles [inputprofi0__1_] on inputprofi0_.InputProfileID=[inputprofi0__1_].FtpInputProfileID left outer join Framework.dbo.CftInputProfiles [inputprofi0__2_] on inputprofi0_.InputProfileID=[inputprofi0__2_].CftInputProfileID left outer join Framework.dbo.SmtpInputProfiles [inputprofi0__3_] on inputprofi0_.InputProfileID=[inputprofi0__3_].SmtpInputProfileID left outer join Framework.dbo.WebsiteInputProfiles [inputprofi0__4_] on inputprofi0_.InputProfileID=[inputprofi0__4_].WebsiteInputProfileID left outer join Framework.dbo.OcrInputProfiles [inputprofi0__5_] on inputprofi0_.InputProfileID=[inputprofi0__5_].OcrInputProfileID where (case when [inputprofi0__1_].FtpInputProfileID is not null then 1 when [inputprofi0__2_].CftInputProfileID is not null then 2 when [inputprofi0__3_].SmtpInputProfileID is not null then 3 when [inputprofi0__4_].WebsiteInputProfileID is not null then 4 when [inputprofi0__5_].OcrInputProfileID is not null then 5 when inputprofi0_.InputProfileID is not null then 0 end=0)
You will note that the discriminator value at the very end of the SQL statement is 0 in both cases, however in the case statement it's being evaluated against has allocated the discriminator value 1 to FtpInputProfile and 3 to SmtpInputProfile.
If I manually edit the SQL statement to set the discriminator value to 1 rather than 0 the DB returns all the rows that represent FtpInputProfiles, so the rest of the SQL seems to be correct, just the conversion of the string representing the type name is not being correctly transformed into the matching descriminator.
To my thinking this must be a bug...
Symon.