All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.persistence.criteria.Path Maven / Gradle / Ivy

Go to download

The Java Persistence API (JPA) : a standard interface-based Java model abstraction of persistence, developed by the JCP.

There is a newer version: 2.2.4
Show newest version
/*
 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
 * which accompanies this distribution.  The Eclipse Public License is available
 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
 * is available at http://www.eclipse.org/org/documents/edl-v10.php.
 */
package javax.persistence.criteria;

import javax.persistence.metamodel.Bindable;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SingularAttribute;

/**
 * Represents a simple or compound attribute path from a bound type or collection, and is a "primitive" expression.
 * @param  the type referenced by the path
 */
public interface Path extends Expression
{
    /**
     * Return the bindable object that corresponds to the path expression.
     * @return bindable object corresponding to the path
     */
    Bindable getModel();

    /**
     * Return the parent "node" in the path or null if no parent.
     * @return parent
     */
    Path getParentPath();

    /**
     * Create a path corresponding to the referenced single-valued attribute.
     * @param attribute single-valued attribute
     * @return path corresponding to the referenced attribute
     * @param  type
     */
     Path get(SingularAttribute attribute);

    /**
     * Create a path corresponding to the referenced collection-valued attribute.
     * @param collection collection-valued attribute
     * @return expression corresponding to the referenced attribute
     * @param  Type
     * @param  Collection type
     */
    > Expression get(PluralAttribute collection);

    /**
     * Create a path corresponding to the referenced map-valued attribute.
     * @param map map-valued attribute
     * @return expression corresponding to the referenced attribute
     * @param  Key Type
     * @param  Value Type
     * @param  Map type
     */
    > Expression get(MapAttribute map);

    /**
     * Create an expression corresponding to the type of the path.
     * @return expression corresponding to the type of the path
     */
    Expression> type();

    // String-based:

    /**
     * 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));
     * 
* @param attributeName name of the attribute * @return path corresponding to the referenced attribute * @throws IllegalStateException if invoked on a path that corresponds to a basic type * @throws IllegalArgumentException if attribute of the given name does not otherwise exist * @param type */ Path get(String attributeName); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy