From my understanding of polymophism I wouldnt call this a polymorphic query:
from User u where u.person.someStudentProperty = whatsoever.
you are referring to a specific subclass in a "non polymorphic" way.
(e.g violatinmg LSP)
just imagine you would have write this query in plain java.
I guess the semantics of the query should be:
get all Students with certain studentproperties ...
from Students s where s.person.someStudentProperty = should work.
from User u where u.person.somePersonProperty = whatsoever..." works correctly ..
yes, because this IS a polymorphic query whilst from User u where u.person.someStudentProperty = whatsoever aint ...
-> IMHO: no bug, it's a feature :)
From my understanding of polymophism I wouldnt call this a polymorphic query
I did not say "polymorphic query". I used the term "polymorphic properties in a query". Anyway, it might be not the most proper way to call it. The question is about using properties declared in an inherited class of the ref type. Obviously the loaded "person" object will be of type Student or Teacher. What I'm interested in is how to query only the users having for "person" a student, that satisfies a certain condition...
Anyway, it might be not the most proper way to call it.
I'd call it subclass specific property ...
(I dont like to call it polymorphic-property because they are very anti-polymorphic (polymophic in terms of generic programing) )
Anyway, no matter how we call this -> about the question about using properties declared in an inherited class of the ref type.
If you want to use a property only a certain subclass defines, you have to use that subclass. (obviously the superclass cant be used)
superclass.subclasspecificproperty cant work.
even in plain java.
in other words: no, this kind of queries dont work.
of course you can do a query for all users and find out
via reflection which u.perons are studnents and for those
which studentproperties= ?
sorry for the long verison of it doesnt work ;)