栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

JPA如何加入这些实体

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

JPA如何加入这些实体

基本上:

select dfrom T_DEBIT dwhere exists (    select r    from T_REQUEST r    where     r.debit.id = d.id and    r.status = SUCCESSFUL)

检查JPQL中的枚举语法,我通常不对实体使用枚举,在此示例中可能是错误的。

作为一种样式问题,我将使用实体名称==类名称而不是实体名称==表名称。它使得JPQL 不是 SQL更清晰的事实

更新

Spring要求解决类似问题。解决这些问题的方法非常系统化:

a)仅使用基本过滤器和以下表达式来重写您的问题:

  1. “存在一些……条件成立”
  2. “对于所有…条件为真”

b)翻译:

  1. 这种情况成为
    exists (select ... where condition)
  2. 这种情况成为
    not exists (select ... where NOT condition)

在Spring的特定问题中,“排除所有成功请求”,目标不是很明确。如果他/她的意思是“在没有成功请求的情况下获得所有借方”,那么您应该这样做:

a)将问题改写为“获取所有借方,以便 对于所有关联的请求,请求状态都不为SUCCESSFUL ”。b)翻译为

select dfrom T_DEBIT dwhere not exists (    select r    from T_REQUEST r    where     -- This is the join condition, so it should not be negated    r.debit.id = d.id and     -- This is the actual filtering condition, negate as this is a FOR ALL    not (r.status != SUCCESSFUL))

然后,您可以简化最后一个条件,得到:

select dfrom T_DEBIT dwhere not exists (    select r    from T_REQUEST r    where     r.debit.id = d.id and    r.status = SUCCESSFUL)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/419646.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号