I have been trying to use Restrictions.Eq( "class",
typeof(SelectOneOptionAnswer)) but this gives me an error as it is
expecting an int rather than a string.
Confirmed this using something similar to the following criteria:
DetachedCriteria criteria =
DetachedCriteria.For<SelectOneOptionAnswer>();
criteria.SetProjection( Projections.ProjectionList()
.Add( Projections.Property("Id"))
.Add( Projections.Property("class"));
Mapping returned Ids to types, the results I get back are:
SelectOneOptionAnswer = 3
RatingScaleAnswer = 5
YesNoAnswer = 6
Running two similar queries across ShortTextAnswer and LongTextAnswer
returns class = 1 for the ShortTextAnswer and class = 2 for the
LongTextAnswer.
The HQL "from SelectOneOptionAnswer where SelectOneOptionAnswer.class
= 'SelectOneOptionAnswer'" produces the following SQL (using SQLite as
the backing db for these tests)
select
selectoneo0_.Id as Id13_,
selectoneo0_1_.Version as Version13_,
selectoneo0_1_.TheQuestion as TheQuest3_13_,
selectoneo0_1_.Comments as Comments13_,
selectoneo0_.SelectedOption as Selected2_16_,
case
when selectoneo0_2_.Id is not null then 5
when selectoneo0_3_.Id is not null then 6
when selectoneo0_.Id is not null then 3
end as clazz_
from
SelectOneOptionAnswer selectoneo0_
inner join Answer selectoneo0_1_ on
selectoneo0_.Id=selectoneo0_1_.Id
left outer join RatingScaleAnswer selectoneo0_2_ on
selectoneo0_.Id=selectoneo0_2_.Id
left outer join YesNoAnswer selectoneo0_3_ on
selectoneo0_.Id=selectoneo0_3_.Id
where
(SelectOneOptionAnswer.class='SelectOneOptionAnswer' )
and errors as there is no class property of SelectOneOptionAnswer in
the database.
Will try updating to trunk and see if that fixes the issue otherwise I
will create an isolated test case to confirm this behaviour and then
figure out where to submit the bug =)
Thanks for the help everyone.
On Sep 18, 5:18 am, "Ayende Rahien" <
aye...@ayende.com> wrote:
> what is the sql generated/
>