Jakarta Persistence (JPA) Interface

jakarta.persistence.criteria.Path<X>

Type Parameters:
<X> - the type referenced by the path
Super Interfaces:
Expression<T>, Selection<T>, TupleElement<X>

Represents a simple or compound attribute path from a bound type or collection, and is a "primitive" expression.
Since:
Jakarta Persistence (JPA) 2.0
The Paths and Types in JPQL and Criteria API article explains how to use Path.

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 path corresponding to the referenced single-valued attribute.
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.
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.
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 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));
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 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
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 bindable object that corresponds to the path expression.
Returns:
bindable object corresponding to the path.
Since:
Jakarta Persistence (JPA) 1.0
Return the parent "node" in the path or null if no parent.
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
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
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
Create an expression corresponding to the type of the path.
Returns:
expression corresponding to the type of the path.
Since:
Jakarta Persistence (JPA) 1.0