javax.persistence.criteria.Path - JPA interface
javax.persistence.criteria
Interface Path<X>
- Superinterfaces:
- Expression<X>, Selection<X>, TupleElement<X>
- Subinterfaces:
- CollectionJoin, From, Join, ListJoin, MapJoin, PluralJoin, Root, SetJoin
Represents a simple or compound attribute path from a bound type or collection, and is a "primitive" expression.
- Since:
- JPA 2.0
Learn how to use JPA criteria API paths in Chapter 4 of the ObjectDB/JPA manual.
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.
- Parameters:
-
name
- alias
- Returns:
- selection item
- Since:
- JPA 2.0
Expression<X> as(Class<X> type)
Perform a typecast upon the expression, returning a new expression object. This method does not cause type conversion: the runtime type is not changed. Warning: may result in a runtime failure.
- Parameters:
-
type
- intended type of the expression
- Returns:
- new expression of the given type
- Since:
- JPA 2.0
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 typeIllegalArgumentException
- if attribute of the given name does not otherwise exist
- Since:
- JPA 2.0
Create a path corresponding to the referenced map-valued attribute.
- Parameters:
-
map
- map-valued attribute
- Returns:
- expression corresponding to the referenced attribute
- Since:
- JPA 2.0
Create a path corresponding to the referenced collection-valued attribute.
- Parameters:
-
collection
- collection-valued attribute
- Returns:
- expression corresponding to the referenced attribute
- Since:
- JPA 2.0
Create a path corresponding to the referenced single-valued attribute.
- Parameters:
-
attribute
- single-valued attribute
- Returns:
- path corresponding to the referenced attribute
- Since:
- JPA 2.0
String getAlias()
Return the alias assigned to the tuple element or null, if no alias has been assigned.
- Returns:
- alias
- Since:
- JPA 2.0
List< Selection<?>> getCompoundSelectionItems()
Return the selection items composing a compound selection. Modifications to the list do not affect the query.
- Returns:
- list of selection items
- Throws:
-
IllegalStateException
- if selection is not a compound selection
- Since:
- JPA 2.0
Class<?> getJavaType()
Return the Java type of the tuple element.
- Returns:
- the Java type of the tuple element
- Since:
- JPA 2.0
Return the bindable object that corresponds to the path expression.
- Returns:
- bindable object corresponding to the path
- Since:
- JPA 2.0
Return the parent "node" in the path or null if no parent.
- Returns:
- parent
- Since:
- JPA 2.0
Create a predicate to test whether the expression is a member of the argument list.
- Parameters:
-
values
- values to be tested against
- Returns:
- predicate testing for membership
- Since:
- JPA 2.0
Create a predicate to test whether the expression is a member of the collection.
- Parameters:
-
values
- collection of values to be tested against
- Returns:
- predicate testing for membership
- Since:
- JPA 2.0
Create a predicate to test whether the expression is a member of the collection.
- Parameters:
-
values
- expression corresponding to collection to be tested against
- Returns:
- predicate testing for membership
- Since:
- JPA 2.0
Create a predicate to test whether the expression is a member of the argument list.
- Parameters:
-
values
- expressions to be tested against
- Returns:
- predicate testing for membership
- Since:
- JPA 2.0
boolean isCompoundSelection()
Whether the selection item is a compound selection.
- Returns:
- boolean indicating whether the selection is a compound selection
- Since:
- JPA 2.0
Create a predicate to test whether the expression is not null.
- Returns:
- predicate testing whether the expression is not null
- Since:
- JPA 2.0
Create a predicate to test whether the expression is null.
- Returns:
- predicate testing whether the expression is null
- Since:
- JPA 2.0
Create an expression corresponding to the type of the path.
- Returns:
- expression corresponding to the type of the path
- Since:
- JPA 2.0