具有3个表的Criteria JPA 2

具有3个表的Criteria JPA 2,第1张

具有3个表的Criteria JPA 2

每次连接都将您从最左边的类型参数带到最右边的参数。因此,

details
我的代码(第二行)的连接从开始
fromUpdates
,即a
Path<Update>
,并在幕后创建了a
Path<Detail>
。由此,您可以建立其他联接。试试看(代码未经测试):

Root<Update> fromUpdates = query.from(Update.class);Join<Update, Detail> details = fromUpdates.join("details");Join<Detail, Associate> associate = details.join("associate");List<Predicate> conditions = new ArrayList();conditions.add(builder.equal(associate.get("associateId"), associateId));conditions.add(builder.isNull(details.get("ack_date")));TypedQuery<Update> typedQuery = em.createQuery(query        .select(fromUpdates)        .where(conditions.toArray(new Predicate[] {}))        .orderBy(builder.asc(fromUpdates.get("updateId")))        .distinct(true));


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5131412.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-17
下一篇2022-11-17

发表评论

登录后才能评论

评论列表(0条)

    保存