JPA Criteria API:LEFT JOIN上的多个条件 [英] JPA Criteria API: Multiple condition on LEFT JOIN

查看:1458
本文介绍了JPA Criteria API:LEFT JOIN上的多个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于以下的联接引用,其第一个联接表达式是由JPA API自动构造的.

I have a join reference like following for which the first join expression is constructed by the JPA API automatically.

CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> c = cb.createTupleQuery();
Root<Demand> demands = c.from(Demand.class);
Join<Demand, Metadata> joinMetadata = demands.join("metadatas", JoinType.LEFT);

但是,我想向我的joinMetadata添加一个附加条件,例如Metadata.type ="AFFECTATION_KEY",但我不知道如何.

but, I would like to add an aditional condition to my joinMetadata like Metadata.type="AFFECTATION_KEY" but I don't know how.

非常感谢您的帮助

推荐答案

JPA始终仅通过映射联接列进行联接. JPA 2.0不支持ON子句,但2.1草案确实具有此支持.

JPA always joins by the mapping join columns, only. JPA 2.0 does not support an ON clause, but the 2.1 draft does have this support.

EclipseLink 2.4支持ON子句,

EclipseLink 2.4 has support for an ON clause,

看, http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#ON

还可以通过Criteria API,使用提供on子句支持的EclipseLink native Expression API,

It is also possible through the Criteria API, using the EclipseLink native Expression API that provides on clause support,

看, http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Criteria#JpaCriteriaBuilder_and_EclipseLink_Extensions

这篇关于JPA Criteria API:LEFT JOIN上的多个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆