Interface Path<X>

Type Parameters:
X - the type referenced by the path
All Superinterfaces:
Expression<X>, Selection<X>, TupleElement<X>
All Known Subinterfaces:
BooleanPath, CollectionJoin<Z,E>, From<Z,X>, Join<Z,X>, ListJoin<Z,E>, MapJoin<Z,K,V>, PluralJoin<Z,C,E>, Root<X>, SetJoin<Z,E>

public interface Path<X> extends Expression<X>
Represents a simple or compound attribute path from a bound type or collection, and is a "primitive" expression.
Since:
2.0
  • Method Details

    • getModel

      @Nonnull Bindable<X> getModel()
      Return the bindable object that corresponds to the path expression.
      Returns:
      bindable object corresponding to the path
    • getParentPath

      @Nullable Path<?> getParentPath()
      Return the parent "node" in the path or null if no parent.
      Returns:
      parent
    • get

      @Nonnull <Y> Path<Y> get(@Nonnull SingularAttribute<? super X, Y> attribute)
      Create a path corresponding to the referenced single-valued attribute.
      Type Parameters:
      Y - the type of the attribute
      Parameters:
      attribute - single-valued attribute
      Returns:
      path corresponding to the referenced attribute
    • get

      @Nonnull BooleanExpression get(@Nonnull BooleanAttribute<? super X> attribute)
      Create a path corresponding to the referenced single-valued attribute.
      Parameters:
      attribute - single-valued attribute
      Returns:
      path corresponding to the referenced attribute
      Since:
      4.0
    • get

      @Nonnull <C extends Comparable<? super C>> ComparableExpression<C> get(@Nonnull ComparableAttribute<? super X, C> attribute)
      Create a path corresponding to the referenced single-valued attribute.
      Type Parameters:
      C - the comparable type of the attribute
      Parameters:
      attribute - single-valued attribute
      Returns:
      path corresponding to the referenced attribute
      Since:
      4.0
    • get

      @Nonnull <T extends Temporal & Comparable<? super T>> TemporalExpression<T> get(@Nonnull TemporalAttribute<? super X, T> attribute)
      Create a path corresponding to the referenced single-valued attribute.
      Type Parameters:
      T - the temporal type of the attribute
      Parameters:
      attribute - single-valued attribute
      Returns:
      path corresponding to the referenced attribute
      Since:
      4.0
    • get

      @Nonnull <N extends Number & Comparable<N>> NumericExpression<N> get(@Nonnull NumericAttribute<? super X, N> attribute)
      Create a path corresponding to the referenced single-valued attribute.
      Type Parameters:
      N - the numeric type of the attribute
      Parameters:
      attribute - single-valued attribute
      Returns:
      path corresponding to the referenced attribute
      Since:
      4.0
    • get

      @Nonnull TextExpression get(@Nonnull TextAttribute<? super X> attribute)
      Create a path corresponding to the referenced single-valued attribute.
      Parameters:
      attribute - single-valued attribute
      Returns:
      path corresponding to the referenced attribute
      Since:
      4.0
    • get

      @Nonnull <E, C extends Collection<E>> PluralExpression<C,E> get(@Nonnull PluralAttribute<? super X, C, E> collection)
      Create a path corresponding to the referenced collection-valued attribute.
      Type Parameters:
      E - the element type of the collection
      C - the collection type
      Parameters:
      collection - collection-valued attribute
      Returns:
      expression corresponding to the referenced attribute
    • get

      @Nonnull <K, V, M extends Map<K,V>> PluralExpression<M,V> get(@Nonnull MapAttribute<? super X, K, V> map)
      Create a path corresponding to the referenced map-valued attribute.
      Type Parameters:
      K - the key type of the map
      V - the value type of the map
      M - the map type
      Parameters:
      map - map-valued attribute
      Returns:
      expression corresponding to the referenced attribute
    • type

      @Nonnull Expression<Class<? extends X>> type()
      Create an expression corresponding to the type of the path.
      Returns:
      expression corresponding to the type of the path
    • get

      @Nonnull <Y> Path<Y> get(@Nonnull 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(SingularAttribute) operation in order to avoid the use of Path variables.

      For example:

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

      rather than:

      CriteriaQuery<Person> q = cb.createQuery(Person.class);
      Root<Person> p = q.from(Person.class);
      Path<Set<String>> nicknames = p.get("nicknames");
      q.select(p)
       .where(cb.isMember("joe", nicknames));
      
      Type Parameters:
      Y - the type of the attribute
      Parameters:
      attributeName - the name of an attribute of the managed type of the path
      Returns:
      path corresponding to the referenced attribute
      Throws:
      IllegalStateException - if invoked on a path that corresponds to a basic type
      IllegalArgumentException - if there is no attribute with the given name
      API note:
      This method accepts a string-valued attribute name, and lacks type safety compared to passing a static metamodel element to get(SingularAttribute). Use of the typesafe version is strongly preferred.
    • treat

      @Nonnull <T extends X> Path<T> treat(@Nonnull Class<T> type)
      Downcast the type of the path to the given type.
      Type Parameters:
      T - the subtype of the path type
      Parameters:
      type - a subtype of the path type
      Returns:
      this path downcast to the given type
      Since:
      4.0