【问题标题】:Casting to specific class in HQL投射到 HQL 中的特定类
【发布时间】:2011-01-11 04:48:55
【问题描述】:

我的情况是这样的..(注意:对于那些使用JBPM的人可能已经熟悉以下数据结构和HB映射)

LongInstance 类从 VariableInstance 扩展而来,在 LongInstance 中覆盖了字段“值”的映射。 VariableInstance 的映射为here,LongInstance 的映射为here

VariableInstance多态映射到TokenVariableMap中的一个集合,映射为here

问题:如何使用成员类的特定/覆盖属性查询多态集合?

我正在寻找这样的东西 “...来自 TokenVariableMaps tvm left join fetch tvm.variableInstances tvi 其中 cast(tvi as LongInstance).value in(:vars)"

【问题讨论】:

    标签: java hibernate hql


    【解决方案1】:

    为什么不:

    .. from TokenVariableMaps tvm, LongInstance li 
    where tvm.variableInstances = li 
    and ...
    

    【讨论】:

      【解决方案2】:

      HQL 支持运行时鉴别器:

      select c from AnyClass where c.class = com.pack.SubClass

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-21
        • 2012-06-09
        • 2017-03-17
        • 2017-12-13
        • 1970-01-01
        • 1970-01-01
        • 2023-01-20
        相关资源
        最近更新 更多