Jakarta Persistence (JPA) Interface

jakarta.persistence.criteria.Join<Z,X>

Type Parameters:
<Z> - the source type of the join
<X> - the target type of the join
Super Interfaces:
From<Z,X>, Path<X>, FetchParent<Z,X>, Expression<X>, Selection<T>, TupleElement<X>

A join to an entity, embeddable, or basic type.
Since:
Jakarta Persistence (JPA) 2.0
The FROM clause (JPQL / Criteria API) article explains how to use Join.

Public Instance Methods

Selection<X> alias(String name)
Assigns an alias to the selection item.
Once assigned, an alias cannot be changed or reassigned. Returns the same selection item.
Inherited from Selection<X>
Parameters:
name - alias
Returns:
selection item.
Since:
Jakarta Persistence (JPA) 1.0
Expression<X> as(Class<X> type)
Perform a typecast upon the expression, returning a new expression object.
Unlike Expression.cast, this method does not cause type conversion: the runtime type is not changed.

Warning: may result in a runtime failure.

Inherited from Expression<T>
Parameters:
type - intended type of the expression
Returns:
new expression of the given type.
See Also:
Since:
Jakarta Persistence (JPA) 1.0
Expression<X> cast(Class<X> type)
Cast this expression to the specified type, returning a new expression object.
Unlike Expression.as, this method does result in a runtime type conversion.

Providers are required to support casting scalar expressions to String, and String expressions to Integer, Long, Float, and Double. Support for typecasts between other basic types is not required.

Inherited from Expression<T>
Parameters:
type - a basic type
Returns:
a scalar expression of the given basic type.
Since:
Jakarta Persistence (JPA) 3.2
Create a predicate to test whether the expression is equal to the argument.
Inherited from Expression<T>
Parameters:
value - expression to be tested against
Returns:
predicate testing for equality.
Since:
Jakarta Persistence (JPA) 3.2
Predicate equalTo(Object value)
Create a predicate to test whether the expression is equal to the argument.
Inherited from Expression<T>
Parameters:
value - value to be tested against
Returns:
predicate testing for equality.
Since:
Jakarta Persistence (JPA) 3.2
Create a fetch join to the specified single-valued attribute using an inner join.
Inherited from FetchParent<Z,X>
Parameters:
attribute - target of the join
Returns:
the resulting fetch join.
Since:
Jakarta Persistence (JPA) 1.0
Create a fetch join to the specified single-valued attribute using the given join type.
Inherited from FetchParent<Z,X>
Parameters:
jt - join type
attribute - target of the join
Returns:
the resulting fetch join.
Since:
Jakarta Persistence (JPA) 1.0
Create a fetch join to the specified collection-valued attribute using an inner join.
Inherited from FetchParent<Z,X>
Parameters:
attribute - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create a fetch join to the specified collection-valued attribute using the given join type.
Inherited from FetchParent<Z,X>
Parameters:
jt - join type
attribute - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Fetch<X,Y> fetch(String attributeName)
Create a fetch join to the specified attribute using an inner join.
Inherited from FetchParent<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
Returns:
the resulting fetch join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
Fetch<X,Y> fetch(String attributeName, JoinType jt)
Create a fetch join to the specified attribute using the given join type.
Inherited from FetchParent<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
jt - join type
Returns:
the resulting fetch join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
Create a path corresponding to the referenced single-valued attribute.
Inherited from Path<X>
Parameters:
attribute - single-valued attribute
Returns:
path corresponding to the referenced attribute.
Since:
Jakarta Persistence (JPA) 1.0
Create a path corresponding to the referenced collection-valued attribute.
Inherited from Path<X>
Parameters:
collection - collection-valued attribute
Returns:
expression corresponding to the referenced attribute.
Since:
Jakarta Persistence (JPA) 1.0
Create a path corresponding to the referenced map-valued attribute.
Inherited from Path<X>
Parameters:
map - map-valued attribute
Returns:
expression corresponding to the referenced attribute.
Since:
Jakarta Persistence (JPA) 1.0
Path<Y> get(String attributeName)
Create a path corresponding to the referenced attribute.

Note: Applications using the string-based API may need to specify the type resulting from the Path.get operation in order to avoid the use of Path variables.

For example:

 CriteriaQuery q = cb.createQuery(Person.class);
 Root p = q.from(Person.class);
 q.select(p)
  .where(cb.isMember("joe",
                     p.>get("nicknames")));

rather than:

 CriteriaQuery q = cb.createQuery(Person.class);
 Root p = q.from(Person.class);
 Path> nicknames = p.get("nicknames");
 q.select(p)
  .where(cb.isMember("joe", nicknames));
Inherited from Path<X>
Parameters:
attributeName - name of the attribute
Returns:
path corresponding to the referenced attribute.
Throws:
IllegalStateException - if invoked on a path that corresponds to a basic type.
IllegalArgumentException - if attribute of the given name does not otherwise exist.
Since:
Jakarta Persistence (JPA) 1.0
String getAlias()
Return the alias assigned to the tuple element or null, if no alias has been assigned.
Inherited from TupleElement<X>
Returns:
alias.
Since:
Jakarta Persistence (JPA) 1.0
Return the metamodel attribute representing the join target, if any, or null if the target of the join is an entity type.
Returns:
metamodel attribute or null.
Since:
Jakarta Persistence (JPA) 1.0
Return the selection items composing a compound selection.
Modifications to the list do not affect the query.
Inherited from Selection<X>
Returns:
list of selection items.
Throws:
IllegalStateException - if selection is not a compound selection.
Since:
Jakarta Persistence (JPA) 1.0
Returns the parent From<Z,X> object from which the correlated From<Z,X> object has been obtained through correlation (use of Subquery.correlate method).
Inherited from From<Z,X>
Returns:
the parent of the correlated From object.
Throws:
IllegalStateException - if the From object has not been obtained through correlation.
Since:
Jakarta Persistence (JPA) 1.0
Return the fetch joins that have been made from this type.
Returns empty set if no fetch joins have been made from this type. Modifications to the set do not affect the query.
Inherited from FetchParent<Z,X>
Returns:
fetch joins made from this type.
Since:
Jakarta Persistence (JPA) 1.0
Class<? extends X> getJavaType()
Return the Java type of the tuple element.
Inherited from TupleElement<X>
Returns:
the Java type of the tuple element.
Since:
Jakarta Persistence (JPA) 1.0
Return the join type.
Returns:
join type.
Since:
Jakarta Persistence (JPA) 1.0
Return the joins that have been made from this bound type.
Returns empty set if no joins have been made from this bound type. Modifications to the set do not affect the query.
Inherited from From<Z,X>
Returns:
joins made from this type.
Since:
Jakarta Persistence (JPA) 1.0
Return the bindable object that corresponds to the path expression.
Inherited from Path<X>
Returns:
bindable object corresponding to the path.
Since:
Jakarta Persistence (JPA) 1.0
Return the predicate that corresponds to the ON restriction(s) on the join, or null if no ON condition has been specified.
Returns:
the ON restriction predicate.
Since:
Jakarta Persistence (JPA) 2.1
Return the parent of the join.
Returns:
join parent.
Since:
Jakarta Persistence (JPA) 1.0
Return the parent "node" in the path or null if no parent.
Inherited from Path<X>
Returns:
parent.
Since:
Jakarta Persistence (JPA) 1.0
Predicate in(Object... values)
Create a predicate to test whether the expression is a member of the argument list.
Inherited from Expression<T>
Parameters:
values - values to be tested against
Returns:
predicate testing for membership.
Since:
Jakarta Persistence (JPA) 1.0
Create a predicate to test whether the expression is a member of the argument list.
Inherited from Expression<T>
Parameters:
values - expressions to be tested against
Returns:
predicate testing for membership.
Since:
Jakarta Persistence (JPA) 1.0
Predicate in(Collection<?> values)
Create a predicate to test whether the expression is a member of the collection.
Inherited from Expression<T>
Parameters:
values - collection of values to be tested against
Returns:
predicate testing for membership.
Since:
Jakarta Persistence (JPA) 1.0
Create a predicate to test whether the expression is a member of the collection.
Inherited from Expression<T>
Parameters:
values - expression corresponding to collection to be tested against
Returns:
predicate testing for membership.
Since:
Jakarta Persistence (JPA) 1.0
Whether the selection item is a compound selection.
Inherited from Selection<X>
Returns:
boolean indicating whether the selection is a compound selection.
Since:
Jakarta Persistence (JPA) 1.0
boolean isCorrelated()
Whether the From<Z,X> object has been obtained as a result of correlation (use of a Subquery.correlate method).
Inherited from From<Z,X>
Returns:
boolean indicating whether the object has been obtained through correlation.
Since:
Jakarta Persistence (JPA) 1.0
Create a predicate to test whether the expression is not null.
Inherited from Expression<T>
Returns:
predicate testing whether the expression is not null.
Since:
Jakarta Persistence (JPA) 1.0
Create a predicate to test whether the expression is null.
Inherited from Expression<T>
Returns:
predicate testing whether the expression is null.
Since:
Jakarta Persistence (JPA) 1.0
Join<X,Y> join(Class<Y> entityClass)
Create and add an inner join to the given entity.
Inherited from From<Z,X>
Parameters:
entityClass - the target entity class
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 3.2
Join<X,Y> join(Class<Y> entityClass, JoinType joinType)
Create and add a join to the given entity.
Inherited from From<Z,X>
Parameters:
entityClass - the target entity class
joinType - join type
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 3.2
Create and add an inner join to the given entity.
Inherited from From<Z,X>
Parameters:
entity - metamodel entity representing the join target
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 3.2
Create and add a join to the given entity.
Inherited from From<Z,X>
Parameters:
entity - metamodel entity representing the join target
joinType - join type
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 3.2
Create an inner join to the specified single-valued attribute.
Inherited from From<Z,X>
Parameters:
attribute - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create a join to the specified single-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
jt - join type
attribute - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create an inner join to the specified Collection<E>-valued attribute.
Inherited from From<Z,X>
Parameters:
collection - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create an inner join to the specified Set<E>-valued attribute.
Inherited from From<Z,X>
Parameters:
set - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create an inner join to the specified List<E>-valued attribute.
Inherited from From<Z,X>
Parameters:
list - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create an inner join to the specified Map<K,V>-valued attribute.
Inherited from From<Z,X>
Parameters:
map - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create a join to the specified Collection<E>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
jt - join type
collection - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create a join to the specified Set<E>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
jt - join type
set - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create a join to the specified List<E>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
jt - join type
list - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Create a join to the specified Map<K,V>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
jt - join type
map - target of the join
Returns:
the resulting join.
Since:
Jakarta Persistence (JPA) 1.0
Join<X,Y> join(String attributeName)
Create an inner join to the specified attribute.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
Join<X,Y> join(String attributeName, JoinType jt)
Create a join to the specified attribute using the given join type.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
jt - join type
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
CollectionJoin<X,Y> joinCollection(String attributeName)
Create an inner join to the specified Collection<E>-valued attribute.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
CollectionJoin<X,Y> joinCollection(String attributeName, JoinType jt)
Create a join to the specified Collection<E>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
jt - join type
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
ListJoin<X,Y> joinList(String attributeName)
Create an inner join to the specified List<E>-valued attribute.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
ListJoin<X,Y> joinList(String attributeName, JoinType jt)
Create a join to the specified List<E>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
jt - join type
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
MapJoin<X,K,V> joinMap(String attributeName)
Create an inner join to the specified Map<K,V>-valued attribute.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
MapJoin<X,K,V> joinMap(String attributeName, JoinType jt)
Create a join to the specified Map<K,V>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
jt - join type
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
SetJoin<X,Y> joinSet(String attributeName)
Create an inner join to the specified Set<E>-valued attribute.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
SetJoin<X,Y> joinSet(String attributeName, JoinType jt)
Create a join to the specified Set<E>-valued attribute using the given join type.
Inherited from From<Z,X>
Parameters:
attributeName - name of the attribute for the target of the join
jt - join type
Returns:
the resulting join.
Throws:
IllegalArgumentException - if attribute of the given name does not exist.
Since:
Jakarta Persistence (JPA) 1.0
Create a predicate to test whether the expression is unequal to the argument.
Inherited from Expression<T>
Parameters:
value - expression to be tested against
Returns:
predicate testing for inequality.
Since:
Jakarta Persistence (JPA) 3.2
Predicate notEqualTo(Object value)
Create a predicate to test whether the expression is unequal to the argument.
Inherited from Expression<T>
Parameters:
value - value to be tested against
Returns:
predicate testing for inequality.
Since:
Jakarta Persistence (JPA) 3.2
Modify the join to restrict the result according to the specified ON condition and return the join object.
Replaces the previous ON condition, if any.
Parameters:
restriction - a simple or compound boolean expression
Returns:
the modified join object.
Since:
Jakarta Persistence (JPA) 2.1
Join<Z,X> on(Predicate... restrictions)
Modify the join to restrict the result according to the specified ON condition and return the join object.
Replaces the previous ON condition, if any.
Parameters:
restrictions - zero or more restriction predicates
Returns:
the modified join object.
Since:
Jakarta Persistence (JPA) 2.1
Create an expression corresponding to the type of the path.
Inherited from Path<X>
Returns:
expression corresponding to the type of the path.
Since:
Jakarta Persistence (JPA) 1.0