【问题标题】:HQL for an any association任何关联的 HQL
【发布时间】:2013-02-26 09:48:51
【问题描述】:

我正在尝试为具有多对任意关联 PaymentTypesRental 编写 HQL。

from rental 
where not exists(
    from PaymentTypes pt where pt.Owner = :rental and type = 'Visa'
)

Owner 是任何关联,其中OwnerIdrental.IdOwnerType = 'Rental'

很遗憾,我不能使用SetEntity 作为预取租金然后调用SetEntity 将非常昂贵。

【问题讨论】:

    标签: hibernate nhibernate hql


    【解决方案1】:

    为什么不尝试像这样的动态查询

    from rental where not exists(from PaymentTypes pt where pt.Owner.id = " + rental.id + " and type = 'Visa')
    

    【讨论】:

    • 不幸的是,这是一个现有的非常复杂的 HQL 查询,我正在尝试添加另一个条件。
    猜你喜欢
    • 1970-01-01
    • 2015-03-14
    • 2013-11-15
    • 2010-11-01
    • 1970-01-01
    • 2017-04-21
    • 2012-09-06
    • 1970-01-01
    • 2015-10-22
    相关资源
    最近更新 更多