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,