2491 words

javax.persistence.criteria.From - JPA interface

javax.persistence.criteria
Interface From<Z,X>

Superinterfaces:
Expression<X>, FetchParent<Z,X>, Path<X>, Selection<X>, TupleElement<X>
Subinterfaces:
CollectionJoin, Join, ListJoin, MapJoin, PluralJoin, Root, SetJoin
Represents a bound type, usually an entity that appears in the from clause, but may also be an embeddable belonging to an entity in the from clause.

Serves as a factory for Joins of associations, embeddables, and collections belonging to the type, and for Paths of attributes belonging to the type.

Since:
JPA 2.0
Selection<X> alias(String name)
Assigns an alias to the selection item.
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.
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
Fetch<X,Y> fetch(String attributeName)
Create a fetch join to the specified attribute using an inner join.
Create a fetch join to the specified attribute using an inner join.
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:
JPA 2.0
Fetch<X,Y> fetch(String attributeName, JoinType jt)
Create a fetch join to the specified attribute using the given join type.
Create a fetch join to the specified attribute using the given join type.
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:
JPA 2.0
Create a fetch join to the specified collection-valued attribute using an inner join.
Create a fetch join to the specified collection-valued attribute using an inner join.
Parameters:
attribute - target of the join
Returns:
the resulting join
Since:
JPA 2.0
Create a fetch join to the specified single-valued attribute using an inner join.
Create a fetch join to the specified single-valued attribute using an inner join.
Parameters:
attribute - target of the join
Returns:
the resulting fetch join
Since:
JPA 2.0
Create a fetch join to the specified collection-valued attribute using the given join type.
Create a fetch join to the specified collection-valued attribute using the given join type.
Parameters:
attribute - target of the join
jt - join type
Returns:
the resulting join
Since:
JPA 2.0
Create a fetch join to the specified single-valued attribute using the given join type.
Create a fetch join to the specified single-valued attribute using the given join type.
Parameters:
attribute - target of the join
jt - join type
Returns:
the resulting fetch join
Since:
JPA 2.0
Path<Y> get(String attributeName)
Create a path corresponding to the referenced attribute.
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<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));

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:
JPA 2.0
Create a path corresponding to the referenced map-valued attribute.
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.
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.
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.
Return the alias assigned to the tuple element or null, if no alias has been assigned.
Returns:
alias
Since:
JPA 2.0
Return the selection items composing a compound selection.
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
Returns the parent From object from which the correlated From object has been obtained through correlation (use of a Subquery correlate method).
Returns the parent From object from which the correlated From object has been obtained through correlation (use of a Subquery correlate method).
Returns:
the parent of the correlated From object
Throws:
IllegalStateException - if the From object has not been obtained through correlation
Since:
JPA 2.0
Return the fetch joins that have been made from this type.
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.
Returns:
fetch joins made from this type
Since:
JPA 2.0
Class<?> getJavaType()
Return the Java type of the tuple element.
Return the Java type of the tuple element.
Returns:
the Java type of the tuple element
Since:
JPA 2.0
Return the joins that have been made from this bound type.
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.
Returns:
joins made from this type
Since:
JPA 2.0
Return the bindable object that corresponds to the path expression.
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.
Return the parent "node" in the path or null if no parent.
Returns:
parent
Since:
JPA 2.0
Predicate in(Object... values)
Create a predicate to test whether the expression is a member of the argument list.
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
Predicate in(Collection<?> values)
Create a predicate to test whether the expression is a member of the collection.
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.
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.
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
Whether the selection item is a compound selection.
Whether the selection item is a compound selection.
Returns:
boolean indicating whether the selection is a compound selection
Since:
JPA 2.0
boolean isCorrelated()
Whether the From object has been obtained as a result of correlation (use of a Subquery correlate method).
Whether the From object has been obtained as a result of correlation (use of a Subquery correlate method).
Returns:
boolean indicating whether the object has been obtained through correlation
Since:
JPA 2.0
Create a predicate to test whether the expression is not null.
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.
Create a predicate to test whether the expression is null.
Returns:
predicate testing whether the expression is null
Since:
JPA 2.0
Join<X,Y> join(String attributeName)
Create an inner join to the specified attribute.
Create an inner join to the specified attribute.
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:
JPA 2.0
Create an inner join to the specified Set-valued attribute.
Create an inner join to the specified Set-valued attribute.
Parameters:
set - target of the join
Returns:
the resulting join
Since:
JPA 2.0
Create an inner join to the specified Map-valued attribute.
Create an inner join to the specified Map-valued attribute.
Parameters:
map - target of the join
Returns:
the resulting join
Since:
JPA 2.0
Create an inner join to the specified List-valued attribute.
Create an inner join to the specified List-valued attribute.
Parameters:
list - target of the join
Returns:
the resulting join
Since:
JPA 2.0
Join<X,Y> join(String attributeName, JoinType jt)
Create a join to the specified attribute using the given join type.
Create a join to the specified attribute using the given join type.
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:
JPA 2.0
Create an inner join to the specified single-valued attribute.
Create an inner join to the specified single-valued attribute.
Parameters:
attribute - target of the join
Returns:
the resulting join
Since:
JPA 2.0
Create an inner join to the specified Collection-valued attribute.
Create an inner join to the specified Collection-valued attribute.
Parameters:
collection - target of the join
Returns:
the resulting join
Since:
JPA 2.0
Create a join to the specified Set-valued attribute using the given join type.
Create a join to the specified Set-valued attribute using the given join type.
Parameters:
set - target of the join
jt - join type
Returns:
the resulting join
Since:
JPA 2.0
Create a join to the specified Map-valued attribute using the given join type.
Create a join to the specified Map-valued attribute using the given join type.
Parameters:
map - target of the join
jt - join type
Returns:
the resulting join
Since:
JPA 2.0
Create a join to the specified List-valued attribute using the given join type.
Create a join to the specified List-valued attribute using the given join type.
Parameters:
list - target of the join
jt - join type
Returns:
the resulting join
Since:
JPA 2.0
Create a join to the specified single-valued attribute using the given join type.
Create a join to the specified single-valued attribute using the given join type.
Parameters:
attribute - target of the join
jt - join type
Returns:
the resulting join
Since:
JPA 2.0
Create a join to the specified Collection-valued attribute using the given join type.
Create a join to the specified Collection-valued attribute using the given join type.
Parameters:
collection - target of the join
jt - join type
Returns:
the resulting join
Since:
JPA 2.0
CollectionJoin<X,Y> joinCollection(String attributeName)
Create an inner join to the specified Collection-valued attribute.
Create an inner join to the specified Collection-valued attribute.
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:
JPA 2.0
CollectionJoin<X,Y> joinCollection(String attributeName, JoinType jt)
Create a join to the specified Collection-valued attribute using the given join type.
Create a join to the specified Collection-valued attribute using the given join type.
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:
JPA 2.0
ListJoin<X,Y> joinList(String attributeName)
Create an inner join to the specified List-valued attribute.
Create an inner join to the specified List-valued attribute.
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:
JPA 2.0
ListJoin<X,Y> joinList(String attributeName, JoinType jt)
Create a join to the specified List-valued attribute using the given join type.
Create a join to the specified List-valued attribute using the given join type.
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:
JPA 2.0
MapJoin<X,K,V> joinMap(String attributeName)
Create an inner join to the specified Map-valued attribute.
Create an inner join to the specified Map-valued attribute.
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:
JPA 2.0
MapJoin<X,K,V> joinMap(String attributeName, JoinType jt)
Create a join to the specified Map-valued attribute using the given join type.
Create a join to the specified Map-valued attribute using the given join type.
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:
JPA 2.0
SetJoin<X,Y> joinSet(String attributeName)
Create an inner join to the specified Set-valued attribute.
Create an inner join to the specified Set-valued attribute.
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:
JPA 2.0
SetJoin<X,Y> joinSet(String attributeName, JoinType jt)
Create a join to the specified Set-valued attribute using the given join type.
Create a join to the specified Set-valued attribute using the given join type.
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:
JPA 2.0
Create an expression corresponding to the type of the path.
Create an expression corresponding to the type of the path.
Returns:
expression corresponding to the type of the path
Since:
JPA 2.0

This documentation page is derived (with some adjustments) from the open source JPA 2 RI (EclipseLink)
and is available under the terms of the Eclipse Public License, v. 1.0 and Eclipse Distribution License, v. 1.0.
Object Relational Mapping (ORM) JPA 2 providers include Hibernate, EclipseLink, TopLink, OpenJPA and DataNucleus.
Object DB is not an ORM JPA implementation but an Object Database for Java with built in JPA 2 support.