【问题标题】:how to use left outer join in hibernate using hibernate query language如何使用休眠查询语言在休眠中使用左外连接
【发布时间】:2016-05-17 15:17:37
【问题描述】:

嗨,我正在尝试使用左外连接执行 hql 查询,它抛出异常为 org.hibernate.hql.ast.QuerySyntaxException:意外令牌:在第 1 行附近,请告诉我此查询中的磨损情况

select * from CreditCardDetails cred left outer join CustomerHistory custHist on cred.creditCardDetailsId=custHist.creditCardDetailsId 和 custHist.cardA=0000

【问题讨论】:

    标签: java mysql hibernate join


    【解决方案1】:

    假设您有一个名为 history 的关联,它将实体 CreditCardDetailsCustomerHistory 相关联。

    from CreditCardDetails cred 
    left outer join cred.history custHist 
    with custHist.cardA=0000
    

    【讨论】:

    • 感谢回复 .. 它的抛出 ...对于上述查询 org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!我
    • 这是因为您缺少两个实体 CreditCardDetails 和 CustomerHistory 之间的关联。 HQL 需要这样的路径才能执行此查询(我更新了查询以显示它是如何完成的)。
    猜你喜欢
    • 1970-01-01
    • 2015-04-17
    • 2016-05-02
    • 2014-09-24
    • 1970-01-01
    • 2011-02-23
    • 2023-03-10
    • 1970-01-01
    • 2012-12-22
    相关资源
    最近更新 更多