Casting to specific class in HQL
My situation is like this.. (note: for those who work with JBPM might already familiar with following data structures and HB mapping)
Class LongI开发者_如何学Pythonnstance extends from VariableInstance, with the mapping for field "value" overridden in LongInstance. The mapping for VariableInstance is here and for LongInstance here.
VariableInstance is polymorphically mapped to a collection in TokenVariableMap, the mapping is here.
The question: how can I query the polymorphic collection using specific/overridden property of the member class?
I'm looking for something like this "... from TokenVariableMaps tvm left join fetch tvm.variableInstances tvi where cast(tvi as LongInstance).value in(:vars)"
Why not:
.. from TokenVariableMaps tvm, LongInstance li
where tvm.variableInstances = li
and ...
HQL supports the runtime discriminator:
select c from AnyClass where c.class = com.pack.SubClass
精彩评论