[hibernate-commits] Hibernate SVN: r17038 - in jpa-api/trunk: src/main/java/javax/persistence and 2 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jul 8 06:58:24 EDT 2009


Author: epbernard
Date: 2009-07-08 06:58:24 -0400 (Wed, 08 Jul 2009)
New Revision: 17038

Added:
   jpa-api/trunk/src/main/java/javax/persistence/Parameter.java
   jpa-api/trunk/src/main/java/javax/persistence/Tuple.java
   jpa-api/trunk/src/main/java/javax/persistence/TupleElement.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/CompoundSelection.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/ParameterExpression.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/PluralJoin.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/BasicType.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/CollectionAttribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/EmbeddableType.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/EntityType.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/ListAttribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/MapAttribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclassType.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/PluralAttribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/SetAttribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/SingularAttribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/StaticMetamodel.java
Removed:
   jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractCollectionJoin.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Parameter.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Result.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/AbstractCollection.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Basic.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Collection.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Embeddable.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Entity.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/List.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Map.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclass.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Member.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Set.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/TypesafeMetamodel.java
Modified:
   jpa-api/trunk/pom.xml
   jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractQuery.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/CollectionJoin.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/CriteriaQuery.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Expression.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Fetch.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/FetchParent.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Join.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/JoinType.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/ListJoin.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/MapJoin.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Order.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Path.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Predicate.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/QueryBuilder.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Root.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Selection.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/SetJoin.java
   jpa-api/trunk/src/main/java/javax/persistence/criteria/Subquery.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Attribute.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Bindable.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Metamodel.java
   jpa-api/trunk/src/main/java/javax/persistence/metamodel/Type.java
Log:
Update to Criteria and metamode as of July 2nd 2009

Modified: jpa-api/trunk/pom.xml
===================================================================
--- jpa-api/trunk/pom.xml	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/pom.xml	2009-07-08 10:58:24 UTC (rev 17038)
@@ -4,7 +4,7 @@
     <groupId>org.hibernate.java-persistence</groupId>
     <artifactId>jpa-api</artifactId>
     <packaging>jar</packaging>
-    <version>2.0.pfd-SNAPSHOT</version>
+    <version>2.0.Beta3-SNAPSHOT</version>
 
     <name>JPA API (developmental)</name>
     <description>

Added: jpa-api/trunk/src/main/java/javax/persistence/Parameter.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/Parameter.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/Parameter.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,25 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * Type for query parameters.
+ * @param <T> the type of the parameter
+ */
+public interface Parameter<T> {
+
+    /**
+     * Return the parameter name, or null if the parameter is
+     * not a named parameter or no name has been assigned.
+     * @return parameter name
+     */
+    String getName();
+
+    /**
+     * Return the parameter position, or null if the parameter
+     * is not a positional parameter.
+     * @return position of parameter
+     */
+    Integer getPosition();
+}
+

Added: jpa-api/trunk/src/main/java/javax/persistence/Tuple.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/Tuple.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/Tuple.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,80 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence;
+
+import java.util.List;
+
+/**
+ * Interface for extracting the elements of a query result tuple.
+ */
+public interface Tuple {
+
+    /**
+     * Get the value of the specified tuple element.
+     * @param tupleElement  tuple element
+     * @return value of tuple element
+     * @throws IllegalArgumentException if tuple element
+     *         does not correspond to an element in the
+     *         query result tuple
+     */
+    <X> X get(TupleElement<X> tupleElement);
+
+    /**
+     * Get the value of the tuple element to which the
+     * specified alias has been assigned.
+     * @param alias  alias assigned to tuple element
+     * @param type of the tuple element
+     * @return value of the tuple element
+     * @throws IllegalArgumentException if alias
+     *         does not correspond to an element in the
+     *         query result tuple or element cannot be
+     *         assigned to the specified type
+     */
+    <X> X get(String alias, Class<X> type);
+
+    /**
+     * Get the value of the tuple element to which the
+     * specified alias has been assigned.
+     * @param alias  alias assigned to tuple element
+     * @return value of the tuple element
+     * @throws IllegalArgumentException if alias
+     *         does not correspond to an element in the
+     *         query result tuple
+     */
+    Object get(String alias);
+
+    /**
+     * Get the value of the element at the specified
+     * position in the result tuple. The first position is 0.
+     * @param i  position in result tuple
+     * @param type  type of the tuple element
+     * @return value of the tuple element
+     * @throws IllegalArgumentException if i exceeds
+     *         length of result tuple  or element cannot be
+     *         assigned to the specified type
+     */
+    <X> X get(int i, Class<X> type);
+
+    /**
+     * Get the value of the element at the specified
+     * position in the result tuple. The first position is 0.
+     * @param i  position in result tuple
+     * @return value of the tuple element
+     * @throws IllegalArgumentException if i exceeds
+     *         length of result tuple
+     */
+    Object get(int i);
+
+    /**
+     * Return the values of the result tuple elements as an array.
+     * @return tuple element values
+     */
+    Object[] toArray();
+
+    /**
+     * Return the tuple elements
+     * @return tuple elements
+     */
+    List<TupleElement<?>> getElements();
+}
+

Added: jpa-api/trunk/src/main/java/javax/persistence/TupleElement.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/TupleElement.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/TupleElement.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,24 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence;
+
+/**
+ * The TupleElement interface defines an element that is returned in
+ * a query result tuple.
+ * @param <T> the type of the element
+ */
+public interface TupleElement<X> {
+
+    /**
+     * Return the Java type of the tuple element.
+     * @return the Java type of the tuple element
+     */
+    Class<X> getJavaType();
+
+    /**
+     * Return the alias assigned to the tuple element or null,
+     * if no alias has been assigned.
+     * @return alias
+     */
+    String getAlias();
+}

Deleted: jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractCollectionJoin.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractCollectionJoin.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractCollectionJoin.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,39 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.criteria;
-
-import javax.persistence.metamodel.AbstractCollection;
-
-/**
- * The interface AbstractCollectionJoin defines functionality
- * that is common to joins to all collection types.  It is
- * not intended to be used directly in query construction.
- *
- * @param <Z> The source type
- * @param <C> The collection type
- * @param <E> The element type of the collection 
- */
-public interface AbstractCollectionJoin<Z, C, E> 
-		extends Join<Z, E> {
-
-    /**
-     * Return the metamodel representation for the collection.
-     * @return metamodel type representing the collection that is
-     *         the target of the join
-     */
-    AbstractCollection<? super Z, C, E> getModel();
-	
-    //TODO: do we need these????
-    /*
-      Predicate isEmpty();
-      Predicate isNotEmpty();
-	
-      Expression<Integer> size();
-
-      Predicate isMember(E elem);
-      Predicate isNotMember(E elem);
-	
-      Predicate isMember(Expression<E> elem);
-      Predicate isNotMember(Expression<E> elem);
-    */
-}

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractQuery.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractQuery.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/AbstractQuery.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,14 +1,14 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.List;
 import java.util.Set;
 
-import javax.persistence.metamodel.Entity;
+import javax.persistence.metamodel.EntityType;
 
 /**
- * The interface AbstractQuery defines functionality that is common
+ * The AbstractQuery interface defines functionality that is common
  * to both top-level queries and subqueries.
  * It is not intended to be used directly in query construction.
  *
@@ -16,9 +16,8 @@
  *         a set of root entities (which may in turn own joins)
  * All queries may have:
  *         a conjunction of restrictions
- *         an ordered list of orders
  */
-public interface AbstractQuery {
+public interface AbstractQuery<T> {
 
     /**
      * Add a query root corresponding to the given entity,
@@ -27,7 +26,7 @@
      *                 of type X
      * @return query root corresponding to the given entity
      */
-    <X> Root<X> from(Entity<X> entity);
+    <X> Root<X> from(EntityType<X> entity);
 
     /**
      * Add a query root corresponding to the given entity,
@@ -42,18 +41,18 @@
      * @return the set of query roots
      */
     Set<Root<?>> getRoots();
-	
+
     /**
      * Modify the query to restrict the query results according
      * to the specified boolean expression.
      * Replaces the previously added restriction(s), if any.
      * @param restriction  a simple or compound boolean expression
      * @return the modified query
-     */    
-    AbstractQuery where(Expression<Boolean> restriction);
+     */
+    AbstractQuery<T> where(Expression<Boolean> restriction);
 
     /**
-     * Modify the query to restrict the query results according 
+     * Modify the query to restrict the query results according
      * to the conjunction of the specified restriction predicates.
      * Replaces the previously added restriction(s), if any.
      * If no restrictions are specified, any previously added
@@ -61,18 +60,18 @@
      * @param restrictions  zero or more restriction predicates
      * @return the modified query
      */
-    AbstractQuery where(Predicate... restrictions);
+    AbstractQuery<T> where(Predicate... restrictions);
 
     /**
      * Specify the expressions that are used to form groups over
      * the query results.
      * Replaces the previous specified grouping expressions, if any.
-     * If no grouping expressions are specified, any previously 
+     * If no grouping expressions are specified, any previously
      * added grouping expressions are simply removed.
      * @param grouping  zero or more grouping expressions
      * @return the modified query
      */
-    AbstractQuery group(Expression<?>... grouping);
+    AbstractQuery<T> groupBy(Expression<?>... grouping);
 
     /**
      * Specify a restriction over the groups of the query.
@@ -80,11 +79,11 @@
      * @param restriction  a simple or compound boolean expression
      * @return the modified query
      */
-    AbstractQuery having(Expression<Boolean> restriction);
+    AbstractQuery<T> having(Expression<Boolean> restriction);
 
     /**
      * Specify restrictions over the groups of the query
-     * according the conjunction of the specified restriction 
+     * according the conjunction of the specified restriction
      * predicates.
      * Replaces the previously added restriction(s), if any.
      * If no restrictions are specified, any previously added
@@ -92,24 +91,9 @@
      * @param restrictions  zero or more restriction predicates
      * @return the modified query
      */
-    AbstractQuery having(Predicate... restrictions);
+    AbstractQuery<T> having(Predicate... restrictions);
 
     /**
-     * Specify the ordering expressions that are used to
-     * order the query results.
-     * Replaces the previous ordering expressions, if any.
-     * If no ordering expressions are specified, the previous
-     * ordering, if any, is simply removed, and results will
-     * be returned in no particular order.
-     * The left-to-right sequence of the ordering expressions
-     * determines the precedence, whereby the leftmost has highest
-     * precedence.
-     * @param o zero or more ordering expression
-     * @return the modified query.
-     */
-    AbstractQuery order(Order... o);
-
-    /**
      * Specify whether duplicate query results will be eliminated.
      * A true value will cause duplicates to be eliminated.
      * A false value will cause duplicates to be retained.
@@ -120,22 +104,22 @@
      *        whether they must be retained
      * @return the modified query.
      */
-    AbstractQuery distinct(boolean distinct);
-    
+    AbstractQuery<T> distinct(boolean distinct);
+
     /**
-     * Return the ordering expressions in order of precedence.
-     * @return the list of ordering expressions
+     *  Return the selection of the query
+     *  @return selection item
      */
-    List<Order> getOrderList();
+    Selection<T> getSelection();
 
     /**
      * Return a list of the grouping expressions
-     * @result the list of grouping expressions
+     * @return the list of grouping expressions
      */
     List<Expression<?>> getGroupList();
 
     /**
-     * Return the predicate that corresponds to the whereclause
+     * Return the predicate that corresponds to the where clause
      * restriction(s).
      * @return where clause predicate
      */
@@ -151,16 +135,17 @@
     /**
      * Return whether duplicate query results must be eliminated or
      * retained.
-     * @result boolean indicating whether duplicate query results must
+     * @return boolean indicating whether duplicate query results must
      *         be eliminated
      */
     boolean isDistinct();
-	
+
     /**
-     * Specify that the query is to be used as a subquery having
-     * the specified return type.
-     * @return subquery corresponding to the query
+     * Create a subquery of the query.
+     * @param type  the subquery result type
+     * @return subquery
      */
     <U> Subquery<U> subquery(Class<U> type);
-	
+
 }
+

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/CollectionJoin.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/CollectionJoin.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/CollectionJoin.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,24 +1,27 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.Collection;
+import javax.persistence.metamodel.CollectionAttribute;
 
 /**
- * The interface CollectionJoin is the type of the result of
- * joining to a collection over an association or element 
+ * The CollectionJoin interface is the type of the result of
+ * joining to a collection over an association or element
  * collection that has been specified as a java.util.Collection.
  *
  * @param <Z> The source type of the join
- * @param <E> The element type of the target oCollection 
+ * @param <E> The element type of the target Collection
  */
-public interface CollectionJoin<Z, E> 
-		extends AbstractCollectionJoin<Z, Collection<E>, E> {
+public interface CollectionJoin<Z, E>
+		extends PluralJoin<Z, Collection<E>, E> {
 
-    /**
-     * Return the metamodel representation for the collection.
-     * @return metamodel type representing the Collection that is
-     *         the target of the join
-     */
-    javax.persistence.metamodel.Collection<? super Z, E> getModel();
+	/**
+	 * Return the metamodel representation for the collection
+	 * attribute.
+	 *
+	 * @return metamodel type representing the Collection that is
+	 *         the target of the join
+	 */
+	CollectionAttribute<? super Z, E> getModel();
 }

Added: jpa-api/trunk/src/main/java/javax/persistence/criteria/CompoundSelection.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/CompoundSelection.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/CompoundSelection.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,20 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.criteria;
+
+import java.util.List;
+
+/**
+ * The CompoundSelection interface defines compound selection item
+ * (tuple, array, or result of constructor).
+ * @param <X> the type of the selection item
+ */
+public interface CompoundSelection<X> extends Selection<X> {
+
+    /**
+     * Return a selection items that were composed to form
+     * the compound selection.
+     * @return list of selection items
+     */
+    List<Selection<?>> getSelectionItems();
+}
\ No newline at end of file

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/CriteriaQuery.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/CriteriaQuery.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/CriteriaQuery.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,91 +1,188 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.List;
+import java.util.Set;
 
-
 /**
- * The interface CriteriaQuery defines functionality that is specific 
+ * The CriteriaQuery interface defines functionality that is specific
  * to top-level queries.
- *
- * A top-level query has an ordered list of selections.
  */
+public interface CriteriaQuery<T> extends AbstractQuery<T> {
 
-public interface CriteriaQuery extends AbstractQuery {
-	
     /**
-     * Specify the items that are to be returned in the query result.
-     * Replaces the previously specified selections, if any.
-     * @param selections  expressions specifying the items that
-     *        are returned in the query result
+     * Specify the item that is to be returned in the query result.
+     * Replaces the previously specified selection(s), if any.
+     * @param selection  selection specifying the item that
+     *        is to be returned in the query result
      * @return the modified query
      */
-    CriteriaQuery select(Selection<?>... selections);
-	
+    CriteriaQuery<T> select(Selection<? extends T> selection);
 
-    //override the return type only:
+    /**
+     * Specify the selection items that are to be returned in the
+     * query result.
+     * Replaces the previously specified selection(s), if any.
+     *
+     * The type of the result of the query execution depends on
+     * the specification of the type of the criteria query object
+     * created as well as the arguments to the multiselect method.
+     * An argument to the multiselect method must not be a tuple-
+     * or array-valued compound selection item.
+     * The semantics of this method are as follows:
+     *
+     * If the type of the criteria query is CriteriaQuery<Tuple>
+     * (i.e., a criteria query object created by either the
+     * createTupleQuery method or by passing a Tuple class argument
+     * to the createQuery method), a Tuple object corresponding to
+     * the arguments of the multiselect method will be instantiated
+     * and returned for each row that results from the query execution.
+     *
+     * If the type of the criteria query is CriteriaQuery<X> for
+     * some user-defined class X (i.e., a criteria query object
+     * created by passing a X class argument to the createQuery
+     * method), then the arguments to the multiselect method will be
+     * passed to the X constructor and an instance of type X will be
+     * returned for each row.
+     *
+     * If the type of the criteria query is CriteriaQuery<X[]> for
+     * some class X, an instance of type X[] will be returned for
+     * each row.   The elements of the array will correspond to the
+     * arguments of the multiselect method.
+     *
+     * If the type of the criteria query is CriteriaQuery<Object>
+     * or if the criteria query was created without specifying a type,
+     * and only a single argument is passed to the multiselect method,
+     * an instance of type Object will be returned for each row.
+     *
+     * If the type of the criteria query is CriteriaQuery<Object>
+     * or if the criteria query was created without specifying a type,
+     * and more than one argument is passed to the multiselect method,
+     * an instance of type Object[] will be instantiated and returned
+     * for each row.  The elements of the array will correspond to the
+     * arguments to the multiselect method.
+     *
+     * @param selections  selection items corresponding to the
+     *        results to be returned by the query
+     * @return the modified query
+     */
+    CriteriaQuery<T> multiselect(Selection<?>... selections);
 
+
     /**
+     * Specify the selection items that are to be returned in the
+     * query result.
+     * Replaces the previously specified selection(s), if any.
+     *
+     * The type of the result of the query execution depends on
+     * the specification of the type of the criteria query object
+     * created as well as the argument to the multiselect method.
+     * An element of the list passed to the multiselect method
+     * must not be a tuple- or array-valued compound selection item.
+     * The semantics of this method are as follows:
+     *
+     * If the type of the criteria query is CriteriaQuery<Tuple>
+     * (i.e., a criteria query object created by either the
+     * createTupleQuery method or by passing a Tuple class argument
+     * to the createQuery method), a Tuple object corresponding to
+     * the elements of the list passed to the multiselect method
+     * will be instantiated and returned for each row that results
+     * from the query execution.
+     *
+     * If the type of the criteria query is CriteriaQuery<X> for
+     * some user-defined class X (i.e., a criteria query object
+     * created by passing a X class argument to the createQuery
+     * method), then the elements of the list passed to the
+     * multiselect method will be passed to the X constructor and
+     * an instance of type X will be returned for each row.
+     *
+     * If the type of the criteria query is CriteriaQuery<X[]> for
+     * some class X, an instance of type X[] will be returned for
+     * each row.   The elements of the array will correspond to the
+     * elements of the list passed to the multiselect method.
+     *
+     * If the type of the criteria query is CriteriaQuery<Object>
+     * or if the criteria query was created without specifying a type,
+     * and the list passed to the multiselect method contains only
+     * a single element, an instance of type Object will be returned
+     * for each row.
+     *
+     * If the type of the criteria query is CriteriaQuery<Object>
+     * or if the criteria query was created without specifying a type,
+     * and the list passed to the multiselect method contains more
+     * than one element, an instance of type Object[] will be
+     * instantiated and returned for each row.  The elements of the
+     * array will correspond to the elements of the list passed to
+     * the multiselect method.
+     *
+     * @param selectionList  list of selection items corresponding
+     *        to the results to be returned by the query
+     * @return the modified query
+     */
+    CriteriaQuery<T> multiselect(List<Selection<?>> selectionList);
+
+
+    /**
      * Modify the query to restrict the query result according
      * to the specified boolean expression.
      * Replaces the previously added restriction(s), if any.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restriction  a simple or compound boolean expression
      * @return the modified query
      */
-    CriteriaQuery where(Expression<Boolean> restriction);
+    CriteriaQuery<T> where(Expression<Boolean> restriction);
 
     /**
-     * Modify the query to restrict the query result according 
+     * Modify the query to restrict the query result according
      * to the conjunction of the specified restriction predicates.
      * Replaces the previously added restriction(s), if any.
      * If no restrictions are specified, any previously added
      * restrictions are simply removed.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restrictions  zero or more restriction predicates
      * @return the modified query
      */
-    CriteriaQuery where(Predicate... restrictions);
+    CriteriaQuery<T> where(Predicate... restrictions);
 
     /**
      * Specify the expressions that are used to form groups over
      * the query results.
      * Replaces the previous specified grouping expressions, if any.
-     * If no grouping expressions are specified, any previously 
+     * If no grouping expressions are specified, any previously
      * added grouping expressions are simply removed.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param grouping  zero or more grouping expressions
      * @return the modified query
      */
-    CriteriaQuery group(Expression<?>... grouping);
+    CriteriaQuery<T> groupBy(Expression<?>... grouping);
 
     /**
      * Specify a restriction over the groups of the query.
      * Replaces the previous having restriction(s), if any.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restriction  a simple or compound boolean expression
      * @return the modified query
      */
-    CriteriaQuery having(Expression<Boolean> restriction);
+    CriteriaQuery<T> having(Expression<Boolean> restriction);
 
     /**
      * Specify restrictions over the groups of the query
-     * according the conjunction of the specified restriction 
+     * according the conjunction of the specified restriction
      * predicates.
      * Replaces the previously added restriction(s), if any.
      * If no restrictions are specified, any previously added
      * restrictions are simply removed.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restrictions  zero or more restriction predicates
      * @return the modified query
      */
-    CriteriaQuery having(Predicate... restrictions);
+    CriteriaQuery<T> having(Predicate... restrictions);
 
     /**
      * Specify the ordering expressions that are used to
@@ -97,12 +194,10 @@
      * The left-to-right sequence of the ordering expressions
      * determines the precedence, whereby the leftmost has highest
      * precedence.
-     * This method only overrides the return type of the 
-     * corresponding AbstractQuery method.
      * @param o  zero or more ordering expressions
      * @return the modified query.
      */
-    CriteriaQuery order(Order... o);
+    CriteriaQuery<T> orderBy(Order... o);
 
     /**
      * Specify whether duplicate query results will be eliminated.
@@ -110,33 +205,35 @@
      * A false value will cause duplicates to be retained.
      * If distinct has not been specified, duplicate results must
      * be retained.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param distinct  boolean value specifying whether duplicate
      *        results must be eliminated from the query result or
      *        whether they must be retained
      * @return the modified query.
      */
-    CriteriaQuery distinct(boolean distinct);
-    
+    CriteriaQuery<T> distinct(boolean distinct);
+
     /**
-     * Return the selection list of the query
-     * @return the list of items to be returned in the query result
+     * Return the result type of the query.
+     * If a result type was specified as an argument to the
+     * createQuery method, that type will be returned.
+     * If the query was created using the createTupleQuery
+     * method, the result type is Tuple.
+     * Otherwise, the result type is Object.
+     * @return result type
      */
-    List<Selection<?>> getSelectionList();
+    Class getResultType();
 
     /**
-     * Bind a parameter
-     * @param  parameter to be bound
-     * @param  value 
-     * @return the modified query.
+     * Return the ordering expressions in order of precedence.
+     * @return the list of ordering expressions
      */
-    <T> CriteriaQuery setParameter(Parameter<T> param, T value);
+    List<Order> getOrderList();
 
-    // Not sure what the intention here is:
-
-    List<Result> getResultList();
-
-    Result getSingleResult();
-	
+    /**
+     * Return the parameters of the query
+     * @return the query parameters
+     */
+    Set<ParameterExpression<?>> getParameters();
 }

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Expression.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Expression.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Expression.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,22 +1,17 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
+import java.util.Collection;
+
 /**
  * Type for query expressions.
  * @param <T> the type of the expression
  */
-
 public interface Expression<T> extends Selection<T> {
 
     /**
-     * Return the Java type of the expression.
-     * @return the Java type of the expression
-     */
-    Class<T> getJavaType();
-
-    /**
-     *  Apply a predicate to test whether the expression is null.
+     *  Apply  a predicate to test whether the expression is null.
      *  @return predicate testing whether the expression is null
      */
     Predicate isNull();
@@ -26,7 +21,7 @@
      *  @return predicate testing whether the expression is not null.
      */
     Predicate isNotNull();
-	
+
     /**
      * Apply a predicate to test whether the expression is a member
      * of the argument list.
@@ -36,9 +31,33 @@
     Predicate in(Object... values);
 
     /**
+     * Apply a predicate to test whether the expression is a member
+     * of the argument list.
+     * @param values
+     * @return predicate testing for membership
+     */
+    Predicate in(Expression<?>... values);
+
+    /**
+     * Apply a predicate to test whether the expression is a member
+     * of the collection.
+     * @param values collection
+     * @return predicate testing for membership
+     */
+    Predicate in(Collection<?> values);
+
+    /**
+     * Apply a predicate to test whether the expression is a member
+     * of the collection.
+     * @param values expression corresponding to collection
+     * @return predicate testing for membership
+     */
+    Predicate in(Expression<Collection<?>> values);
+
+    /**
      * Perform a typecast upon the expression.
      * Warning: may result in a runtime failure.
-     * @param type 
+     * @param type
      * @return expression
      */
     <X> Expression<X> as(Class<X> type);

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Fetch.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Fetch.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Fetch.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,21 +1,21 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.Member;
+import javax.persistence.metamodel.Attribute;
 
 /**
- * Represents a join-fetched association or attribute
+ * Represents a join-fetched association or attribute.
  * @param <Z>
  * @param <X>
  */
 public interface Fetch<Z, X> extends FetchParent<Z, X> {
 
     /**
-     * Return the metamodel member corresponding to the fetch join.
-     * @return metamodel member type for the join
+     * Return the metamodel attribute corresponding to the fetch join.
+     * @return metamodel attribute for the join
      */
-    Member<? extends Z, X> getMember();
+    Attribute<? super Z, ?> getAttribute();
 
     /**
      * Return the parent of the fetched item.

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/FetchParent.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/FetchParent.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/FetchParent.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,9 +1,9 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.AbstractCollection;
-import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
 
 /**
  * Represents an element of the from clause which may
@@ -21,54 +21,61 @@
     java.util.Set<Fetch<X, ?>> getFetches();
 
     /**
-     *  Fetch join to the specified attribute.
-     *  @param assoc  target of the join
+     *  Fetch join to the specified single-valued attribute
+     *  using an inner join.
+     *  @param attribute  target of the join
      *  @return the resulting fetch join
-     */	
-    <Y> Fetch<X, Y> fetch(Attribute<? super X, Y> assoc);
+     */
+    <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> attribute);
 
     /**
-     *  Fetch join to the specified attribute using the given
-     *  join type.
-     *  @param assoc  target of the join
+     *  Fetch join to the specified single-valued attribute using
+     *  the given join type.
+     *  @param attribute  target of the join
      *  @param jt  join type
      *  @return the resulting fetch join
-     */	
-    <Y> Fetch<X, Y> fetch(Attribute<? super X, Y> assoc, JoinType jt);
+     */
+    <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> attribute, JoinType jt);
 
     /**
-     *  Join to the specified collection. 
-     *  @param assoc  target of the join
+     *  Fetch join to the specified collection-valued attribute
+     *  using an inner join.
+     *  @param attribute  target of the join
      *  @return the resulting join
      */
-    <Y> Fetch<X, Y> fetch(AbstractCollection<? super X, ?, Y> assoc);
-	
+    <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> attribute);
+
     /**
-     *  Join to the specified collection using the given join type.
-     *  @param assoc  target of the join
+     *  Fetch join to the specified collection-valued attribute
+     *  using the given join type.
+     *  @param attribute  target of the join
      *  @param jt  join type
      *  @return the resulting join
      */
-    <Y> Fetch<X, Y> fetch(AbstractCollection<? super X, ?, Y> assoc, JoinType jt);
-	
+    <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> attribute, JoinType jt);
 
-    //Untypesafe:
-	
+
+    //String-based:
+
     /**
-     *  Fetch join to the specified attribute or association.
-     *  @param name  name of the attribute or association for the
-     *               target of the join
+     *  Fetch join to the specified attribute using an inner join.
+     *  @param attributeName  name of the attribute for the
+     *         target of the join
      *  @return the resulting fetch join
-     */	
-    <Y> Fetch<X, Y> fetch(String assocName);
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
+     */
+    <Y> Fetch<X, Y> fetch(String attributeName);
 
     /**
-     *  Fetch join to the specified attribute or association using
-     *  the given join type.
-     *  @param name  name of the attribute or association for the
+     *  Fetch join to the specified attribute using the given
+     *  join type.
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @param jt  join type
      *  @return the resulting fetch join
-     */	
-    <Y> Fetch<X, Y> fetch(String assocName, JoinType jt);
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
+     */
+    <Y> Fetch<X, Y> fetch(String attributeName, JoinType jt);
 }

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,22 +1,22 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.Attribute;
-import javax.persistence.metamodel.Collection;
-import javax.persistence.metamodel.List;
-import javax.persistence.metamodel.Map;
-import javax.persistence.metamodel.Set;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.SetAttribute;
 
 /**
  * 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 
+ * 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.
- * @param <Z> 
- * @param <X> 
+ * @param <Z>
+ * @param <X>
  */
 public interface From<Z, X> extends Path<X>, FetchParent<Z, X> {
 
@@ -25,178 +25,207 @@
      *  @return joins made from this type
      */
     java.util.Set<Join<X, ?>> getJoins();
-	
+
     /**
-     *  Join to the specified attribute.
+     *  Join to the specified single-valued attribute using an
+     *  inner join.
      *  @param attribute  target of the join
      *  @return the resulting join
      */
-    <Y> Join<X, Y> join(Attribute<? super X, Y> attribute);
+    <Y> Join<X, Y> join(SingularAttribute<? super X, Y> attribute);
 
     /**
-     *  Join to the specified attribute, using the given join type.
+     *  Join to the specified single-valued attribute using the
+     *  given join type.
      *  @param attribute  target of the join
-     *  @param jt  join type 
+     *  @param jt  join type
      *  @return the resulting join
      */
-    <Y> Join<X, Y> join(Attribute<? super X, Y> attribute, JoinType jt);
-	
+    <Y> Join<X, Y> join(SingularAttribute<? super X, Y> attribute, JoinType jt);
 
     /**
-     *  Join to the specified Collection-valued attribute.
+     *  Join to the specified Collection-valued attribute using
+     *  an inner join.
      *  @param collection  target of the join
      *  @return the resulting join
      */
-    <Y> CollectionJoin<X, Y> join(Collection<? super X, Y> collection);
+    <Y> CollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection);
 
     /**
-     *  Join to the specified Set-valued attribute.
+     *  Join to the specified Set-valued attribute using an inner
+     *  join.
      *  @param set  target of the join
      *  @return the resulting join
      */
-    <Y> SetJoin<X, Y> join(Set<? super X, Y> set);
+    <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set);
 
     /**
-     *  Join to the specified List-valued attribute.
+     *  Join to the specified List-valued attribute using an inner
+     *  join.
      *  @param list  target of the join
      *  @return the resulting join
      */
-    <Y> ListJoin<X, Y> join(List<? super X, Y> list);
+    <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list);
 
     /**
-     *  Join to the specified Map-valued attribute.
+     *  Join to the specified Map-valued attribute using an inner
+     *  join.
      *  @param map  target of the join
      *  @return the resulting join
      */
-    <K, V> MapJoin<X, K, V> join(Map<? super X, K, V> map);
-	
+    <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map);
 
     /**
-     *  Join to the specified Collection-valued attribute, 
+     *  Join to the specified Collection-valued attribute
      *  using the given join type.
      *  @param collection  target of the join
-     *  @param jt  join type 
+     *  @param jt  join type
      *  @return the resulting join
      */
-    <Y> CollectionJoin<X, Y> join(Collection<? super X, Y> collection, JoinType jt);
+    <Y> CollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection, JoinType jt);
 
     /**
-     *  Join to the specified Set-valued attribute, using the given
+     *  Join to the specified Set-valued attribute using the given
      *  join type.
      *  @param set  target of the join
-     *  @param jt  join type 
+     *  @param jt  join type
      *  @return the resulting join
      */
-    <Y> SetJoin<X, Y> join(Set<? super X, Y> set, JoinType jt);
+    <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set, JoinType jt);
 
     /**
-     *  Join to the specified List-valued attribute, using the
+     *  Join to the specified List-valued attribute using the
      *  given join type.
      *  @param list  target of the join
-     *  @param jt  join type 
+     *  @param jt  join type
      *  @return the resulting join
      */
-    <Y> ListJoin<X, Y> join(List<? super X, Y> list, JoinType jt);
+    <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list, JoinType jt);
 
     /**
-     *  Join to the specified Map-valued attribute, using the
+     *  Join to the specified Map-valued attribute using the
      *  given join type.
      *  @param map  target of the join
-     *  @param jt  join type 
+     *  @param jt  join type
      *  @return the resulting join
      */
-    <K, V> MapJoin<X, K, V> join(Map<? super X, K, V> map, JoinType jt);
+    <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map, JoinType jt);
 
-	
-    //Untypesafe:
 
+    //String-based:
+
     /**
-     *  Join to the specified attribute. 
-     *  @param name  name of the attribute for the 
+     *  Join to the specified attribute using an inner join.
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> Join<W, Y> join(String attributeName);	
+    <X, Y> Join<X, Y> join(String attributeName);
 
     /**
-     *  Join to the specified Collection-valued attribute. 
-     *  @param name  name of the attribute for the 
+     *  Join to the specified Collection-valued attribute using an
+     *  inner join.
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> CollectionJoin<W, Y> joinCollection(String attributeName);	
+    <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName);
 
     /**
-     *  Join to the specified Set-valued attribute. 
-     *  @param name  name of the attribute for the 
+     *  Join to the specified Set-valued attribute using an inner
+     *  join.
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> SetJoin<W, Y> joinSet(String attributeName);	
+    <X, Y> SetJoin<X, Y> joinSet(String attributeName);
 
     /**
-     *  Join to the specified List-valued attribute. 
-     *  @param name  name of the attribute for the 
+     *  Join to the specified List-valued attribute using an inner
+     *  join.
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> ListJoin<W, Y> joinList(String attributeName);	
+    <X, Y> ListJoin<X, Y> joinList(String attributeName);
 
     /**
-     *  Join to the specified Map-valued attribute. 
-     *  @param name  name of the attribute for the 
+     *  Join to the specified Map-valued attribute using an inner
+     *  join.
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, K, V> MapJoin<W, K, V> joinMap(String attributeName);	
+    <X, K, V> MapJoin<X, K, V> joinMap(String attributeName);
 
+
     /**
-     *  Join to the specified attribute, using the given
+     *  Join to the specified attribute using the given
      *  join type.
-     *  @param name  name of the attribute for the 
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @param jt  join type
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> Join<W, Y> join(String attributeName, JoinType jt);	
+    <X, Y> Join<X, Y> join(String attributeName, JoinType jt);
 
     /**
-     *  Join to the specified Collection-valued attribute, using 
+     *  Join to the specified Collection-valued attribute using
      *  the given join type.
-     *  @param name  name of the attribute for the 
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @param jt  join type
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> CollectionJoin<W, Y> joinCollection(String attributeName, JoinType jt);	
+    <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt);
 
     /**
-     *  Join to the specified Set-valued attribute, using 
+     *  Join to the specified Set-valued attribute using
      *  the given join type.
-     *  @param name  name of the attribute for the 
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @param jt  join type
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> SetJoin<W, Y> joinSet(String attributeName, JoinType jt);	
+    <X, Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt);
 
     /**
-     *  Join to the specified List-valued attribute, using 
+     *  Join to the specified List-valued attribute using
      *  the given join type.
-     *  @param name  name of the attribute for the 
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @param jt  join type
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, Y> ListJoin<W, Y> joinList(String attributeName, JoinType jt);	
+    <X, Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt);
 
     /**
-     *  Join to the specified Mapn-valued attribute, using 
+     *  Join to the specified Map-valued attribute using
      *  the given join type.
-     *  @param name  name of the attribute for the 
+     *  @param attributeName  name of the attribute for the
      *               target of the join
      *  @param jt  join type
      *  @return the resulting join
+     *  @throws IllegalArgumentException if attribute of the given
+     *          name does not exist
      */
-    <W, K, V> MapJoin<W, K, V> joinMap(String attributeName, JoinType jt);	
+    <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt);
 }

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Join.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Join.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Join.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,8 +1,8 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.Member;
+import javax.persistence.metamodel.Attribute;
 
 /**
  * A join to an entity or embeddable type.
@@ -12,10 +12,10 @@
 public interface Join<Z, X> extends From<Z, X> {
 
     /**
-     * Return the metamodel member corresponding to the join.
-     * @return metamodel member type for the join
+     * Return the metamodel attribute corresponding to the join.
+     * @return metamodel attribute corresponding to the join
      */
-    Member<? extends Z, X> getMember();
+    Attribute<? super Z, ?> getAttribute();
 
     /**
      * Return the parent of the join.

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/JoinType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/JoinType.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/JoinType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,5 +1,5 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 /**
@@ -8,3 +8,4 @@
 public enum JoinType {
 	INNER, LEFT, RIGHT
 }
+

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/ListJoin.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/ListJoin.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/ListJoin.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,27 +1,27 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.List;
+import javax.persistence.metamodel.ListAttribute;
 
 /**
- * The interface ListJoin is the type of the result of
- * joining to a collection over an association or element 
+ * The ListJoin interface is the type of the result of
+ * joining to a collection over an association or element
  * collection that has been specified as a java.util.List.
  *
  * @param <Z> The source type of the join
  * @param <E> The element type of the target List
  */
+public interface ListJoin<Z, E>
+		extends PluralJoin<Z, List<E>, E> {
 
-public interface ListJoin<Z, E> 
-		extends AbstractCollectionJoin<Z, List<E>, E> {
-
     /**
-     * Return the metamodel representation for the list.
+     * Return the metamodel representation for the list attribute.
      * @return metamodel type representing the List that is
      *         the target of the join
      */
-    javax.persistence.metamodel.List<? super Z, E> getModel();
+    ListAttribute<? super Z, E> getModel();
 
     /**
      * Return an expression that corresponds to the index of
@@ -30,7 +30,7 @@
      * This method must only be invoked upon an object that
      * represents an association or element collection for
      * which an order column has been defined.
-     * @return Expression denoting the index
+     * @return expression denoting the index
      */
     Expression<Integer> index();
-}
+}
\ No newline at end of file

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/MapJoin.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/MapJoin.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/MapJoin.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,59 +1,60 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.Map;
+import javax.persistence.metamodel.MapAttribute;
 
 /**
- * The interface MapJoin is the type of the result of
- * joining to a collection over an association or element 
+ * The MapJoin interface is the type of the result of
+ * joining to a collection over an association or element
  * collection that has been specified as a java.util.Map.
  *
  * @param <Z> The source type of the join
  * @param <K> The type of the target Map key
  * @param <V> The type of the target Map value
  */
+public interface MapJoin<Z, K, V>
+		extends PluralJoin<Z, Map<K, V>, V> {
 
-public interface MapJoin<Z, K, V> 
-		extends AbstractCollectionJoin<Z, Map<K, V>, V> {
-
     /**
-     * Return the metamodel representation for the map.
+     * Return the metamodel representation for the map attribute.
      * @return metamodel type representing the Map that is
      *         the target of the join
      */
-    javax.persistence.metamodel.Map<? super Z, K, V> getModel();
-    
+    MapAttribute<? super Z, K, V> getModel();
+
     /**
-     * Specify a join over the map key.
+     * Specify an inner join over the map key.
      * @return result of joining over the map key
      */
     Join<Map<K, V>, K> joinKey();
 
     /**
-     * Specify a join over the map key, using the given 
+     * Specify a join over the map key using the given
      * join type.
      * @param jt  join type
      * @return result of joining over the map key
-     */    
+     */
     Join<Map<K, V>, K> joinKey(JoinType jt);
-    
+
     /**
      * Return a path expression that corresponds to the map key.
-     * @return Path corresponding to map key
+     * @return path corresponding to map key
      */
     Path<K> key();
-    
+
     /**
      * Return a path expression that corresponds to the map value.
      * This method is for stylistic use only: it just returns this.
-     * @return Path corresponding to the map value
+     * @return path corresponding to the map value
      */
-    Path<V> value(); //Unnecessary - just returns this
-    
+    Path<V> value();
+
     /**
      * Return an expression that corresponds to the map entry.
-     * @return Expression corresponding to the map entry
+     * @return expression corresponding to the map entry
      */
     Expression<Map.Entry<K, V>> entry();
 }
+

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Order.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Order.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Order.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,5 +1,5 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 /**
@@ -9,19 +9,19 @@
 
    /**
     * Switch the ordering.
+    * @return a new Order instance with the reversed ordering
     */
-    void reverse();
+    Order reverse();
 
-    /**
-     * Whether ascending ordering is in effect.
-     * @return boolean indicating whether ordering is ascending
-     */
-     boolean isAscending();
+   /**
+    * Whether ascending ordering is in effect.
+    * @return boolean indicating whether ordering is ascending
+    */
+    boolean isAscending();
 
-    /**
-     * Return the expression that is used for ordering.
-     * @return expression used for ordering
-     */
-    <T extends Comparable<T>> Expression<T> getExpression();
-}
-
+   /**
+    * Return the expression that is used for ordering.
+    * @return expression used for ordering
+    */
+   <T extends Comparable<T>> Expression<T> getExpression();
+}
\ No newline at end of file

Deleted: jpa-api/trunk/src/main/java/javax/persistence/criteria/Parameter.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Parameter.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Parameter.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,10 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.criteria;
-
-/**
- * Type for query parameters.
- * @param <T> the type of the parameter
- */
-
-public interface Parameter<T> extends Expression<T> {}

Added: jpa-api/trunk/src/main/java/javax/persistence/criteria/ParameterExpression.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/ParameterExpression.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/ParameterExpression.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,13 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.criteria;
+
+import javax.persistence.Parameter;
+
+
+/**
+ * Type of criteria query parameter expressions.
+ * @param <T> the type of the parameter expression
+ */
+public interface ParameterExpression<T> extends Parameter<T>, Expression<T> {}
+

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Path.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Path.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Path.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,65 +1,74 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.AbstractCollection;
-import javax.persistence.metamodel.Attribute;
 import javax.persistence.metamodel.Bindable;
-import javax.persistence.metamodel.Map;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
 
 /**
- * Represents a simple or compound attribute path from a 
+ * Represents a simple or compound attribute path from a
  * bound type or collection, and is a "primitive" expression.
  * @param <X>  Type referenced by the path
  */
 public interface Path<X> extends Expression<X> {
 
-    Bindable<X> getModel(); //TODO: what does this return for a collection key, value? null?
-    
     /**
-     *  Return the parent "node" in the path.
+     * Return the bindable object that corresponds to the
+     * path expression.
+     * @return bindable object corresponding to the path
+     */
+    Bindable<X> getModel();
+
+    /**
+     *  Return the parent "node" in the path or null if no parent.
      *  @return parent
      */
     Path<?> getParentPath();
-	
+
     /**
-     *  Return the path corresponding to the referenced 
-     *  non-collection valued attribute.
-     *  @param model attribute
+     *  Return the path corresponding to the referenced
+     *  single-valued attribute.
+     *  @param attribute single-valued attribute
      *  @return path corresponding to the referenced attribute
      */
-    <Y> Path<Y> get(Attribute<? super X, Y> model);
+    <Y> Path<Y> get(SingularAttribute<? super X, Y> attribute);
 
     /**
-     *  Return the path corresponding to the referenced 
+     *  Return the path corresponding to the referenced
      *  collection-valued attribute.
      *  @param collection collection-valued attribute
-     *  @return path corresponding to the referenced attribute
+     *  @return expression corresponding to the referenced attribute
      */
-    <E, C extends java.util.Collection<E>> Expression<C> get(AbstractCollection<X, C, E> collection);
+    <E, C extends java.util.Collection<E>> Expression<C> get(PluralAttribute<X, C, E> collection);
 
     /**
-     *  Return the path corresponding to the referenced 
+     *  Return the path corresponding to the referenced
      *  map-valued attribute.
-     *  @param collection map-valued attribute
-     *  @return path corresponding to the referenced attribute
+     *  @param map map-valued attribute
+     *  @return expression corresponding to the referenced attribute
      */
-    <K, V, M extends java.util.Map<K, V>> Expression<M> get(Map<X, K, V> collection);
+    <K, V, M extends java.util.Map<K, V>> Expression<M> get(MapAttribute<X, K, V> map);
 
     /**
      *  Return an expression corresponding to the type of the path.
      *  @return expression corresponding to the type of the path
      */
     Expression<Class<? extends X>> type();
-	
 
-    //Untypesafe:
-	
+
+    //String-based:
+
     /**
-     *  Return the path corresponding to the referenced 
+     *  Return the path corresponding to the referenced
      *  attribute.
-     *  @param attName  name of the attribute
+     *  @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
      */
-    <Y> Path<Y> get(String attName);
+    <Y> Path<Y> get(String attributeName);
 }

Added: jpa-api/trunk/src/main/java/javax/persistence/criteria/PluralJoin.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/PluralJoin.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/PluralJoin.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,25 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.criteria;
+
+import javax.persistence.metamodel.PluralAttribute;
+
+/**
+ * The PluralJoin interface defines functionality
+ * that is common to joins to all collection types.  It is
+ * not intended to be used directly in query construction.
+ *
+ * @param <Z> The source type
+ * @param <C> The collection type
+ * @param <E> The element type of the collection
+ */
+public interface PluralJoin<Z, C, E> extends Join<Z, E> {
+
+    /**
+     * Return the metamodel representation for the collection-valued
+     * attribute corresponding to the join.
+     * @return metamodel collection-valued attribute corresponding
+     *         to the target of the join
+     */
+    PluralAttribute<? super Z, C, E> getModel();
+}

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Predicate.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Predicate.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Predicate.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,5 +1,5 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.List;
@@ -11,41 +11,33 @@
  * single conjunct.
  */
 public interface Predicate extends Expression<Boolean> {
-	
+
 	public static enum BooleanOperator {
 		AND, OR
 	}
-	
+
     /**
      * Return the boolean operator for the predicate.
-     * If the predicate is simple, this is AND
+     * If the predicate is simple, this is AND.
      * @return boolean operator for the predicate
      */
     BooleanOperator getOperator();
-    
+
     /**
-     * Has negation been applied to the predicate?
+     * Has negation been applied to the predicate.
      * @return boolean indicating if the predicate has been negated
      */
     boolean isNegated();
 
     /**
      * Return the top-level conjuncts or disjuncts of the predicate.
-     * @return list boolean expressions forming the predicate
+     * @return list of boolean expressions forming the predicate
      */
     List<Expression<Boolean>> getExpressions();
-	
+
     /**
-     * Add another operand to the predicate.
-     * Whether the operand is added as a conjunct or disjunct is
-     * determined by the predicate operator.
-     * @return the resulting compound predicate
+     * Create a negation of the predicate.
+     * @return negated predicate
      */
-    Predicate add(Expression<Boolean> s);
-	
-    /**
-     * Apply negation to the predicate.
-     * @return the negated predicate
-     */
     Predicate negate();
-}
+}
\ No newline at end of file

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/QueryBuilder.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/QueryBuilder.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/QueryBuilder.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,5 +1,5 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.math.BigDecimal;
@@ -7,1293 +7,1655 @@
 import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
+import javax.persistence.Tuple;
 
 /**
- * Factory object for queries, select lists, restrictions, 
+ * Factory object for queries, select lists, restrictions,
  * expressions, orderings
- * The factory methods are all typesafe. 
- * Note that Predicate is used instead of Expression<Boolean> 
- * in this API in order to work around the fact that Java 
+ * Note that Predicate is used instead of Expression<Boolean>
+ * in this API in order to work around the fact that Java
  * generics are not compatible with varags.
  */
 public interface QueryBuilder {
 
-    /**
-     *  Create a Criteria query object.
-     *  @return query object
-     */
-    CriteriaQuery create();
+	/**
+	 * Create a Criteria query object.
+	 *
+	 * @return query object
+	 */
+	CriteriaQuery<Object> createQuery();
 
-	
-    //select new Foo(...) equivalent:
+	/**
+	 * Create a Criteria query object with the specified result
+	 * type.
+	 *
+	 * @param resultClass type of the query result
+	 *
+	 * @return query object
+	 */
+	<T> CriteriaQuery<T> createQuery(Class<T> resultClass);
 
-    /**
-     * Define a select list item corresponding to a constructor.
-     * @param result  class whose instance is to be constructed
-     * @param selections  arguments to the constructor
-     * @return selection item
-     */
-    <Y> Selection<Y> select(Class<Y> result, Selection<?>... selections);
-	
+	/**
+	 * Create a Criteria query object that returns a tuple of
+	 * objects as its result.
+	 *
+	 * @return query object
+	 */
+	CriteriaQuery<Tuple> createTupleQuery();
 
-    //ordering:
-	
-    /**
-     * Create an ordering by the ascending value of the expression.
-     * @param x  expression used to define the ordering
-     * @return ascending ordering corresponding to the expression
-     */
-    Order asc(Expression<?> x);
 
-    /**
-     * Create an ordering by the descending value of the expression.
-     * @param x  expression used to define the ordering
-     * @return descending ordering corresponding to the expression
-     */
-    Order desc(Expression<?> x);
+	/**
+	 * Define a selection item corresponding to a constructor.
+	 *
+	 * @param result class whose instance is to be constructed
+	 * @param selections arguments to the constructor
+	 *
+	 * @return compound selection item
+	 *
+	 * @throws IllegalArgumentException if an argument is a tuple- or
+	 *                                  array-valued selection item
+	 */
+	<Y> CompoundSelection<Y> construct(Class<Y> result, Selection<?>... selections);
 
-	
-    //aggregate functions:
-	
-    /**
-     * Create an expression applying the avg operation.
-     * @param x  expression representing input value to avg operation
-     * @return avg expression
-     */
-    <N extends Number> Expression<N> avg(Expression<N> x);
+	/**
+	 * Define a tuple-valued selection item
+	 *
+	 * @param selections selection items
+	 *
+	 * @return tuple-valued compound selection
+	 *
+	 * @throws IllegalArgumentException if an argument is a tuple- or
+	 *                                  array-valued selection item
+	 */
+	CompoundSelection<Tuple> tuple(Selection<?>... selections);
 
-    /**
-     * Create an expression applying the sum operation.
-     * @param x  expression representing input value to sum operation
-     * @return sum expression
-     */
-    <N extends Number> Expression<N> sum(Expression<N> x);
-    
-    /**
-     * Create an expression applying the max operation.
-     * @param x  expression representing input value to max operation
-     * @return max expression
-     */
-    <N extends Number> Expression<N> max(Expression<N> x);
-    
-    /**
-     * Create an expression applying the min operation.
-     * @param x  expression representing input value to min operation
-     * @return min expression
-     */
-    <N extends Number> Expression<N> min(Expression<N> x);
-	
-    /**
-     * Create an expression applying the count operation.
-     * @param x  expression representing input value to count 
-     * 				operation
-     * @return count expression
-     */
-    Expression<Integer> count(Expression<?> x);
+	/**
+	 * Define a array-valued selection item
+	 *
+	 * @param selections selection items
+	 *
+	 * @return array-valued compound selection
+	 *
+	 * @throws IllegalArgumentException if an argument is a tuple- or
+	 *                                  array-valued selection item
+	 */
+	CompoundSelection<Object[]> array(Selection<?>... selections);
 
-    /**
-     * Create an expression applying the count distinct operation.
-     * @param x  expression representing input value to 
-     *        count distinct operation
-     * @return count distinct expression
-     */
-    Expression<Integer> countDistinct(Expression<?> x);
-	
 
+	//ordering:
 
-    //subqueries:
-	
-    /**
-     * Create a predicate testing the existence of a subquery result.
-     * @param subquery  subquery whose result is to be tested
-     * @return exists predicate
-     */
-    Predicate exists(Subquery<?> subquery);
-	
-    /**
-     * Create a predicate corresponding to an all expression over the
-     * subquery results.
-     * @param subquery
-     * @return all expression
-     */
-    <Y> Expression<Y> all(Subquery<Y> subquery);
-	
-    // Not sure what this does.  Why is this needed?
-    <Y> Expression<Y> none(Subquery<Y> subquery);
-	
-    /**
-     * Create a predicate corresponding to a some expression over the
-     * subquery results.  This is equivalent to an any expression.
-     * @param subquery
-     * @return all expression
-     */
-    <Y> Expression<Y> some(Subquery<Y> subquery);
-	
-    /**
-     * Create a predicate corresponding to an any expression over the
-     * subquery results.  This is equivalent to a some expression.
-     * @param subquery
-     * @return any expression
-     */	
-    <Y> Expression<Y> any(Subquery<Y> subquery);
+	/**
+	 * Create an ordering by the ascending value of the expression.
+	 *
+	 * @param x expression used to define the ordering
+	 *
+	 * @return ascending ordering corresponding to the expression
+	 */
+	Order asc(Expression<?> x);
 
+	/**
+	 * Create an ordering by the descending value of the expression.
+	 *
+	 * @param x expression used to define the ordering
+	 *
+	 * @return descending ordering corresponding to the expression
+	 */
+	Order desc(Expression<?> x);
 
-    //boolean functions:
-	
-    /**
-     * Create a conjunction of the given boolean expressions.
-     * @param x  boolean expression
-     * @param y  boolean expression
-     * @return and predicate
-     */
-    Predicate and(Expression<Boolean> x, Expression<Boolean> y);
 
-    /**
-     * Create a disjunction of the given boolean expressions.
-     * @param x  boolean expression
-     * @param y  boolean expression
-     * @return or predicate
-     */
-    Predicate or(Expression<Boolean> x, Expression<Boolean> y);
-    
-    /**
-     * Create a conjunction of the given restriction predicates.
-     * @param restrictions  zero or more restriction predicates
-     * @return and predicate
-     */
-    Predicate and(Predicate... restrictions);
+	//aggregate functions:
 
-    /**
-     * Create a conjunction of the given restriction predicates.
-     * @param restrictions  zero or more restriction predicates
-     * @return and predicate
-     */
-    Predicate or(Predicate... restrictions);
+	/**
+	 * Create an expression applying the avg operation.
+	 *
+	 * @param x expression representing input value to avg operation
+	 *
+	 * @return avg expression
+	 */
+	<N extends Number> Expression<Double> avg(Expression<N> x);
 
-    /**
-     * Create a negation of the given restriction. 
-     * @param restriction  restriction expression
-     * @return not predicate
-     */
-    Predicate not(Expression<Boolean> restriction);
-	
-    /**
-     * Create a conjunction (with zero conjuncts).
-     * @return and predicate
-     */
-    Predicate conjunction();
+	/**
+	 * Create an expression applying the sum operation.
+	 *
+	 * @param x expression representing input value to sum operation
+	 *
+	 * @return sum expression
+	 */
+	<N extends Number> Expression<N> sum(Expression<N> x);
 
-    /**
-     * Create a disjunction (with zero disjuncts).
-     * @return or predicate
-     */
-    Predicate disjunction();
+	/**
+	 * Create an expression applying the numerical max operation.
+	 *
+	 * @param x expression representing input value to max operation
+	 *
+	 * @return max expression
+	 */
+	<N extends Number> Expression<N> max(Expression<N> x);
 
-	
-    //turn Expression<Boolean> into a Predicate
-    //useful for use with varargs methods	
+	/**
+	 * Create an expression applying the numerical min operation.
+	 *
+	 * @param x expression representing input value to min operation
+	 *
+	 * @return min expression
+	 */
+	<N extends Number> Expression<N> min(Expression<N> x);
 
-    /**
-     * Create a predicate testing for a true value.
-     * @param x  expression to be tested if true
-     * @return predicate
-     */
-    Predicate isTrue(Expression<Boolean> x);
+	/**
+	 * Create an aggregate expression for finding the greatest of
+	 * the values (strings, dates, etc).
+	 *
+	 * @param x expression representing input value to greatest
+	 * operation
+	 *
+	 * @return greatest expression
+	 */
+	<X extends Comparable<X>> Expression<X> greatest(Expression<X> x);
 
-    /**
-     * Create a predicate testing for a false value.
-     * @param x  expression to be tested if false
-     * @return predicate
-     */
-    Predicate isFalse(Expression<Boolean> x);
+	/**
+	 * Create an aggregate expression for finding the least of
+	 * the values (strings, dates, etc).
+	 *
+	 * @param x expression representing input value to least
+	 * operation
+	 *
+	 * @return least expression
+	 */
+	<X extends Comparable<X>> Expression<X> least(Expression<X> x);
 
-	
-    //equality:
-	
-    /**
-     * Create a predicate for testing the arguments for equality.
-     * @param x  expression
-     * @param y  expression
-     * @return equality predicate
-     */
-    Predicate equal(Expression<?> x, Expression<?> y);
+	/**
+	 * Create an expression applying the count operation.
+	 *
+	 * @param x expression representing input value to count
+	 * operation
+	 *
+	 * @return count expression
+	 */
+	Expression<Long> count(Expression<?> x);
 
-    /**
-     * Create a predicate for testing the arguments for inequality.
-     * @param x  expression
-     * @param y  expression
-     * @return inequality predicate
-     */
-    Predicate notEqual(Expression<?> x, Expression<?> y);
-	
-    /**
-     * Create a predicate for testing the arguments for equality.
-     * @param x  expression
-     * @param y  object
-     * @return equality predicate
-     */
-    Predicate equal(Expression<?> x, Object y);
-	
-    /**
-     * Create a predicate for testing the arguments for inequality.
-     * @param x  expression
-     * @param y  object
-     * @return inequality predicate
-     */
-    Predicate notEqual(Expression<?> x, Object y);
+	/**
+	 * Create an expression applying the count distinct operation.
+	 *
+	 * @param x expression representing input value to
+	 * count distinct operation
+	 *
+	 * @return count distinct expression
+	 */
+	Expression<Long> countDistinct(Expression<?> x);
 
-    //Predicate in(Expression<?> expression, Object... values);
-	
-    //<Y> Predicate equal(Expression<Y> x, Expression<Y> y);
-    //<Y> Predicate notEqual(Expression<Y> x, Expression<Y> y);
-    //<Y> Predicate equal(Expression<Y> x, Y y);
-    //<Y> Predicate notEqual(Expression<Y> x, Y y);
-    //Predicate eq(Expression<? extends Number> x, Expression<? extends Number> y);
-    //Predicate ne(Expression<? extends Number> x, Expression<? extends Number> y);
-    //Predicate eq(Expression<? extends Number> x, Number y);
-    //Predicate ne(Expression<? extends Number> x, Number y);
-	
-    //comparisons for generic (non-numeric) operands:
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than the second.
-     * @param x  expression
-     * @param y  expression
-     * @return greater-than predicate
-     */	
-    <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y);
+	//subqueries:
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than the second.
-     * @param x  expression
-     * @param y  expression
-     * @return less-than predicate
-     */	
-    <Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Expression<? extends Y> y);
-    
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than or equal to the second.
-     * @param x  expression
-     * @param y  expression
-     * @return greater-than-or-equal predicate
-     */	
-    <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
-	
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than or equal to the second.
-     * @param x  expression
-     * @param y  expression
-     * @return less-than-or-equal predicate
-     */	
-    <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
+	/**
+	 * Create a predicate testing the existence of a subquery result.
+	 *
+	 * @param subquery subquery whose result is to be tested
+	 *
+	 * @return exists predicate
+	 */
+	Predicate exists(Subquery<?> subquery);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * between the second and third arguments in value.
-     * @param v  expression 
-     * @param x  expression
-     * @param y  expression
-     * @return between predicate
-     */	
-    <Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Expression<? extends Y> x, Expression<? extends Y> y);
-	
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than the second.
-     * @param x  expression
-     * @param y  value
-     * @return greater-than predicate
-     */	
-    <Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Y y);
+	/**
+	 * Create a predicate corresponding to an all expression over the
+	 * subquery results.
+	 *
+	 * @param subquery
+	 *
+	 * @return all expression
+	 */
+	<Y> Expression<Y> all(Subquery<Y> subquery);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than the second.
-     * @param x  expression
-     * @param y  value
-     * @return less-than predicate
-     */	
-    <Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Y y);
+	/**
+	 * Create a predicate corresponding to a some expression over the
+	 * subquery results.  This is equivalent to an any expression.
+	 *
+	 * @param subquery
+	 *
+	 * @return all expression
+	 */
+	<Y> Expression<Y> some(Subquery<Y> subquery);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than or equal to the second.
-     * @param x  expression
-     * @param y  value
-     * @return greater-than-or-equal predicate
-     */	
-    <Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Y y);
+	/**
+	 * Create a predicate corresponding to an any expression over the
+	 * subquery results.  This is equivalent to a some expression.
+	 *
+	 * @param subquery
+	 *
+	 * @return any expression
+	 */
+	<Y> Expression<Y> any(Subquery<Y> subquery);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than or equal to the second.
-     * @param x  expression
-     * @param y  value
-     * @return less-than-or-equal predicate
-     */	
-    <Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Y y);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * between the second and third arguments in value.
-     * @param v  expression 
-     * @param x  value
-     * @param y  value
-     * @return between predicate
-     */	
-    <Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Y x, Y y);
-	
+	//boolean functions:
 
-    //comparisons for numeric operands:
-	
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than the second.
-     * @param x  expression
-     * @param y  expression
-     * @return greater-than predicate
-     */	
-    Predicate gt(Expression<? extends Number> x, Expression<? extends Number> y);
+	/**
+	 * Create a conjunction of the given boolean expressions.
+	 *
+	 * @param x boolean expression
+	 * @param y boolean expression
+	 *
+	 * @return and predicate
+	 */
+	Predicate and(Expression<Boolean> x, Expression<Boolean> y);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than the second.
-     * @param x  expression
-     * @param y  expression
-     * @return less-than predicate
-     */	
-    Predicate lt(Expression<? extends Number> x, Expression<? extends Number> y);
+	/**
+	 * Create a disjunction of the given boolean expressions.
+	 *
+	 * @param x boolean expression
+	 * @param y boolean expression
+	 *
+	 * @return or predicate
+	 */
+	Predicate or(Expression<Boolean> x, Expression<Boolean> y);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than or equal to the second.
-     * @param x  expression
-     * @param y  expression
-     * @return greater-than-or-equal predicate
-     */	
-    Predicate ge(Expression<? extends Number> x, Expression<? extends Number> y);
+	/**
+	 * Create a conjunction of the given restriction predicates.
+	 * A conjunction of zero predicates is true.
+	 *
+	 * @param restriction zero or more restriction predicates
+	 *
+	 * @return and predicate
+	 */
+	Predicate and(Predicate... restrictions);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than or equal to the second.
-     * @param x  expression
-     * @param y  expression
-     * @return less-than-or-equal predicate
-     */	
-    Predicate le(Expression<? extends Number> x, Expression<? extends Number> y);
+	/**
+	 * Create a conjunction of the given restriction predicates.
+	 * A disjunction of zero predicates is false.
+	 *
+	 * @param restriction zero or more restriction predicates
+	 *
+	 * @return or predicate
+	 */
+	Predicate or(Predicate... restrictions);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than the second.
-     * @param x  expression
-     * @param y  value
-     * @return greater-than predicate
-     */		
-    Predicate gt(Expression<? extends Number> x, Number y);
+	/**
+	 * Create a negation of the given restriction.
+	 *
+	 * @param restriction restriction expression
+	 *
+	 * @return not predicate
+	 */
+	Predicate not(Expression<Boolean> restriction);
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than the second.
-     * @param x  expression
-     * @param y  value
-     * @return less-than predicate
-     */	
-    Predicate lt(Expression<? extends Number> x, Number y);
+	/**
+	 * Create a conjunction (with zero conjuncts).
+	 * A conjunction with zero conjuncts is true.
+	 *
+	 * @return and predicate
+	 */
+	Predicate conjunction();
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * greater than or equal to the second.
-     * @param x  expression
-     * @param y  value
-     * @return greater-than-or-equal predicate
-     */	
-    Predicate ge(Expression<? extends Number> x, Number y);
+	/**
+	 * Create a disjunction (with zero disjuncts).
+	 * A disjunction with zero disjuncts is false.
+	 *
+	 * @return or predicate
+	 */
+	Predicate disjunction();
 
-    /**
-     * Create a predicate for testing whether the first argument is 
-     * less than or equal to the second.
-     * @param x  expression
-     * @param y  value
-     * @return less-than-or-equal predicate
-     */	
-    Predicate le(Expression<? extends Number> x, Number y);
-	
 
-    //numerical operations:
-	
-    /**
-     * Create an expression that returns the arithmetic negation
-     * of its argument.
-     * @param x expression
-     * @return negated expression
-     */
-    <N extends Number> Expression<N> neg(Expression<N> x);
+	//turn Expression<Boolean> into a Predicate
+	//useful for use with varargs methods
 
-    /**
-     * Create an expression that returns the absolute value
-     * of its argument.
-     * @param x expression
-     * @return absolute value
-     */
-    <N extends Number> Expression<N> abs(Expression<N> x);
-	
+	/**
+	 * Create a predicate testing for a true value.
+	 *
+	 * @param x expression to be tested if true
+	 *
+	 * @return predicate
+	 */
+	Predicate isTrue(Expression<Boolean> x);
 
-    //TODO: support builder pattern for sums, products
+	/**
+	 * Create a predicate testing for a false value.
+	 *
+	 * @param x expression to be tested if false
+	 *
+	 * @return predicate
+	 */
+	Predicate isFalse(Expression<Boolean> x);
 
-    /**
-     * Create an expression that returns the sum
-     * of its arguments.
-     * @param x expression
-     * @param y expression
-     * @return sum
-     */
-    <N extends Number> Expression<N> sum(Expression<? extends N> x, Expression<? extends N> y);
 
-    /**
-     * Create an expression that returns the product
-     * of its arguments.
-     * @param x expression
-     * @param y expression
-     * @return product
-     */
-    <N extends Number> Expression<N> prod(Expression<? extends N> x, Expression<? extends N> y);
+	//null tests:
 
-    /**
-     * Create an expression that returns the difference
-     * between its arguments.
-     * @param x expression
-     * @param y expression
-     * @return difference
-     */
-    <N extends Number> Expression<N> diff(Expression<? extends N> x, Expression<? extends N> y);
-	
-    /**
-     * Create an expression that returns the sum
-     * of its arguments.
-     * @param x expression
-     * @param y value
-     * @return sum
-     */
-    <N extends Number> Expression<N> sum(Expression<? extends N> x, N y);
+	/**
+	 * Create a predicate to test whether the expression is null.
+	 *
+	 * @param x expression
+	 *
+	 * @return predicate
+	 */
+	Predicate isNull(Expression<?> x);
 
-    /**
-     * Create an expression that returns the product
-     * of its arguments.
-     * @param x expression
-     * @param y value
-     * @return product
-     */
-    <N extends Number> Expression<N> prod(Expression<? extends N> x, N y);
+	/**
+	 * Create a predicate to test whether the expression is not null.
+	 *
+	 * @param x expression
+	 *
+	 * @return predicate
+	 */
+	Predicate isNotNull(Expression<?> x);
 
-    /**
-     * Create an expression that returns the difference
-     * between its arguments.
-     * @param x expression
-     * @param y value
-     * @return difference
-     */
-    <N extends Number> Expression<N> diff(Expression<? extends N> x, N y);
+	//equality:
 
-    /**
-     * Create an expression that returns the sum
-     * of its arguments.
-     * @param x value
-     * @param y expression
-     * @return sum
-     */
-    <N extends Number> Expression<N> sum(N x, Expression<? extends N> y);
+	/**
+	 * Create a predicate for testing the arguments for equality.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return equality predicate
+	 */
+	Predicate equal(Expression<?> x, Expression<?> y);
 
-    /**
-     * Create an expression that returns the product
-     * of its arguments.
-     * @param x value
-     * @param y expression
-     * @return product
-     */
-    <N extends Number> Expression<N> prod(N x, Expression<? extends N> y);
+	/**
+	 * Create a predicate for testing the arguments for inequality.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return inequality predicate
+	 */
+	Predicate notEqual(Expression<?> x, Expression<?> y);
 
-    /**
-     * Create an expression that returns the difference
-     * between its arguments.
-     * @param x value
-     * @param y expression
-     * @return difference
-     */
-    <N extends Number> Expression<N> diff(N x, Expression<? extends N> y);
-	
-    /**
-     * Create an expression that returns the quotient
-     * of its arguments.
-     * @param x expression
-     * @param y expression
-     * @return quotient
-     */
-    Expression<Number> quot(Expression<? extends Number> x, Expression<? extends Number> y);
+	/**
+	 * Create a predicate for testing the arguments for equality.
+	 *
+	 * @param x expression
+	 * @param y object
+	 *
+	 * @return equality predicate
+	 */
+	Predicate equal(Expression<?> x, Object y);
 
-    /**
-     * Create an expression that returns the quotient
-     * of its arguments.
-     * @param x expression
-     * @param y value
-     * @return quotient
-     */
-    Expression<Number> quot(Expression<? extends Number> x, Number y);
+	/**
+	 * Create a predicate for testing the arguments for inequality.
+	 *
+	 * @param x expression
+	 * @param y object
+	 *
+	 * @return inequality predicate
+	 */
+	Predicate notEqual(Expression<?> x, Object y);
 
-    /**
-     * Create an expression that returns the quotient
-     * of its arguments.
-     * @param x value
-     * @param y expression
-     * @return quotient
-     */
-    Expression<Number> quot(Number x, Expression<? extends Number> y);
-	
-    /**
-     * Create an expression that returns the modulus
-     * of its arguments.
-     * @param x expression
-     * @param y expression
-     * @return modulus
-     */
-    Expression<Integer> mod(Expression<Integer> x, Expression<Integer> y);
-	
-    /**
-     * Create an expression that returns the modulus
-     * of its arguments.
-     * @param x expression
-     * @param y value
-     * @return modulus
-     */
-    Expression<Integer> mod(Expression<Integer> x, Integer y);
 
-    /**
-     * Create an expression that returns the modulus
-     * of its arguments.
-     * @param x value
-     * @param y expression
-     * @return modulus
-     */
-    Expression<Integer> mod(Integer x, Expression<Integer> y);
+	//comparisons for generic (non-numeric) operands:
 
-    /**
-     * Create an expression that returns the square root
-     * of its argument.
-     * @param x expression
-     * @return modulus
-     */	
-    Expression<Double> sqrt(Expression<? extends Number> x);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return greater-than predicate
+	 */
+	<Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y);
 
-	
-    //typecasts:
-    
-    /**
-     * Typecast
-     * @param number expression
-     * @return Expression<Long>
-     */	
-    Expression<Long> toLong(Expression<? extends Number> number);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return less-than predicate
+	 */
+	<Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Expression<? extends Y> y);
 
-    /**
-     * Typecast
-     * @param number expression
-     * @return Expression<Integer>
-     */	
-    Expression<Integer> toInteger(Expression<? extends Number> number);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return greater-than-or-equal predicate
+	 */
+	<Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
 
-    /**
-     * Typecast
-     * @param number expression
-     * @return Expression<Float>
-     */	
-    Expression<Float> toFloat(Expression<? extends Number> number);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return less-than-or-equal predicate
+	 */
+	<Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Expression<? extends Y> y);
 
-    /**
-     * Typecast     * @param numeric expression
-     * @return Expression<Double>
-     */	
-    Expression<Double> toDouble(Expression<? extends Number> number);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * between the second and third arguments in value.
+	 *
+	 * @param v expression
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return between predicate
+	 */
+	<Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Expression<? extends Y> x, Expression<? extends Y> y);
 
-    /**
-     * Typecast
-     * @param number expression
-     * @return Expression<BigDecimal>
-     */	
-    Expression<BigDecimal> toBigDecimal(Expression<? extends Number> number);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return greater-than predicate
+	 */
+	<Y extends Comparable<Y>> Predicate greaterThan(Expression<? extends Y> x, Y y);
 
-    /**
-     * Typecast
-     * @param number expression
-     * @return Expression<BigInteger>
-     */	
-    Expression<BigInteger> toBigInteger(Expression<? extends Number> number);
-	
-    /**
-     * Typecast
-     * @param character expression
-     * @return Expression<String>
-     */	
-    Expression<String> toString(Expression<Character> character);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return less-than predicate
+	 */
+	<Y extends Comparable<Y>> Predicate lessThan(Expression<? extends Y> x, Y y);
 
-	
-    //literals:
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return greater-than-or-equal predicate
+	 */
+	<Y extends Comparable<Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Y y);
 
-    /*
-     * Create an expression literal
-     * @param value
-     * @return expression literal
-     */
-    <T> Expression<T> literal(T value);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return less-than-or-equal predicate
+	 */
+	<Y extends Comparable<Y>> Predicate lessThanOrEqualTo(Expression<? extends Y> x, Y y);
 
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * between the second and third arguments in value.
+	 *
+	 * @param v expression
+	 * @param x value
+	 * @param y value
+	 *
+	 * @return between predicate
+	 */
+	<Y extends Comparable<Y>> Predicate between(Expression<? extends Y> v, Y x, Y y);
 
-    //parameters:
 
-    /*
-     * Create a parameter.
-     * @param parameter class
-     * @return parameter
-     */
-    <T> Parameter<T> parameter(Class<T> paramClass);
+	//comparisons for numeric operands:
 
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return greater-than predicate
+	 */
+	Predicate gt(Expression<? extends Number> x, Expression<? extends Number> y);
 
-    //collection operations:
-	
-    /**
-     *  Create a predicate that tests whether a collection is empty.
-     *  @param collection expression
-     *  @return predicate
-     */
-    <C extends Collection<?>> Predicate isEmpty(Expression<C> collection);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return less-than predicate
+	 */
+	Predicate lt(Expression<? extends Number> x, Expression<? extends Number> y);
 
-    /**
-     *  Create a predicate that tests whether a collection is
-     *  not empty.
-     *  @param collection expression
-     *  @return predicate
-     */
-    <C extends Collection<?>> Predicate isNotEmpty(Expression<C> collection);
-	
-    /**
-     * Create an expression that tests the size of a collection.
-     * @param collection
-     * @return size expression
-     */ 
-    <C extends Collection<?>> Expression<Integer> size(C collection);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return greater-than-or-equal predicate
+	 */
+	Predicate ge(Expression<? extends Number> x, Expression<? extends Number> y);
 
-    /**
-     * Create an expression that tests the size of a collection.
-     * @param collection
-     * @return size expression
-     */ 
-    <C extends java.util.Collection<?>> Expression<Integer> size(Expression<C> collection);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return less-than-or-equal predicate
+	 */
+	Predicate le(Expression<? extends Number> x, Expression<? extends Number> y);
 
-    /**
-     *  Create a predicate that tests whether an element is
-     *  a member of a collection.
-     *  @param elem element
-     *  @param collection expression
-     *  @return predicate
-     */
-    <E, C extends Collection<E>> Predicate isMember(E elem, Expression<C> collection);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return greater-than predicate
+	 */
+	Predicate gt(Expression<? extends Number> x, Number y);
 
-    /**
-     *  Create a predicate that tests whether an element is
-     *  not a member of a collection.
-     *  @param elem element
-     *  @param collection expression
-     *  @return predicate
-     */
-    <E, C extends Collection<E>> Predicate isNotMember(E elem, Expression<C> collection);
-	
-    /**
-     *  Create a predicate that tests whether an element is
-     *  a member of a collection.
-     *  @param elem elementexpression
-     *  @param collection expression
-     *  @return predicate
-     */
-    <E, C extends Collection<E>> Predicate isMember(Expression<E> elem, Expression<C> collection);
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return less-than predicate
+	 */
+	Predicate lt(Expression<? extends Number> x, Number y);
 
-    /**
-     *  Create a predicate that tests whether an element is
-     *  not a member of a collection.
-     *  @param elem elementexpression
-     *  @param collection expression
-     *  @return predicate
-     */
-    <E, C extends Collection<E>> Predicate isNotMember(Expression<E> elem, Expression<C> collection);
-	
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * greater than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return greater-than-or-equal predicate
+	 */
+	Predicate ge(Expression<? extends Number> x, Number y);
 
-    //get the values and keys collections of the Map, which may then
-    //be passed to size(), isMember(), isEmpty(), etc
+	/**
+	 * Create a predicate for testing whether the first argument is
+	 * less than or equal to the second.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return less-than-or-equal predicate
+	 */
+	Predicate le(Expression<? extends Number> x, Number y);
 
-    /**
-     * Create an expression that returns the values of a map.
-     * @param map
-     * @return collection expression
-     */
-    <V, M extends Map<?, V>> Expression<Collection<V>> values(M map);
 
-    /**
-     * Create an expression that returns the keys of a map.
-     * @param map
-     * @return set expression
-     */
-    <K, M extends Map<K, ?>> Expression<Set<K>> keySet(M map);
+	//numerical operations:
 
-	
-    //string functions:
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * satisfies the given pattern.
-     * @param x  string expression
-     * @param pattern  string expression
-     * @return like predicate
-     */
-    Predicate like(Expression<String> x, Expression<String> pattern);
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * satisfies the given pattern.
-     * @param x  string expression
-     * @param pattern  string expression
-     * @param escapeChar  escape character expression
-     * @return like predicate
-     */
-    Predicate like(Expression<String> x, Expression<String> pattern, Expression<Character> escapeChar);
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * satisfies the given pattern.
-     * @param x  string expression
-     * @param pattern  string expression
-     * @param escapeChar  escape character
-     * @return like predicate
-     */
-    Predicate like(Expression<String> x, Expression<String> pattern, char escapeChar);
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * satisfies the given pattern.
-     * @param x  string expression
-     * @param pattern  string 
-     * @return like predicate
-     */
-    Predicate like(Expression<String> x, String pattern);
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * satisfies the given pattern.
-     * @param x  string expression
-     * @param pattern  string 
-     * @param escapeChar  escape character expression
-     * @return like predicate
-     */
-    Predicate like(Expression<String> x, String pattern, Expression<Character> escapeChar);
+	/**
+	 * Create an expression that returns the arithmetic negation
+	 * of its argument.
+	 *
+	 * @param x expression
+	 *
+	 * @return arithmetic negation
+	 */
+	<N extends Number> Expression<N> neg(Expression<N> x);
 
-    /**
-     * Create a predicate for testing whether the expression
-     * satisfies the given pattern.
-     * @param x  string expression
-     * @param pattern  string 
-     * @param escapeChar  escape character
-     * @return like predicate
-     */
-    Predicate like(Expression<String> x, String pattern, char escapeChar);
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * does not satisfy the given pattern.
-     * @param x  string expression
-     * @param pattern  string expression
-     * @return like predicate
-     */
-    Predicate notLike(Expression<String> x, Expression<String> pattern);
+	/**
+	 * Create an expression that returns the absolute value
+	 * of its argument.
+	 *
+	 * @param x expression
+	 *
+	 * @return absolute value
+	 */
+	<N extends Number> Expression<N> abs(Expression<N> x);
 
-    /**
-     * Create a predicate for testing whether the expression
-     * does not satisfy the given pattern.
-     * @param x  string expression
-     * @param pattern  string expression
-     * @param escapeChar  escape character expression
-     * @return like predicate
-     */
-    Predicate notLike(Expression<String> x, Expression<String> pattern, Expression<Character> escapeChar);
+	/**
+	 * Create an expression that returns the sum
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return sum
+	 */
+	<N extends Number> Expression<N> sum(Expression<? extends N> x, Expression<? extends N> y);
 
-    /**
-     * Create a predicate for testing whether the expression
-     * does not satisfy the given pattern.
-     * @param x  string expression
-     * @param pattern  string expression
-     * @param escapeChar  escape character
-     * @return like predicate
-     */
-    Predicate notLike(Expression<String> x, Expression<String> pattern, char escapeChar);
-	
-    /**
-     * Create a predicate for testing whether the expression
-     * does not satisfy the given pattern.
-     * @param x  string expression
-     * @param pattern  string 
-     * @return like predicate
-     */
-    Predicate notLike(Expression<String> x, String pattern);
+	/**
+	 * Create an expression that returns the product
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return product
+	 */
+	<N extends Number> Expression<N> prod(Expression<? extends N> x, Expression<? extends N> y);
 
-    /**
-     * Create a predicate for testing whether the expression
-     * does not satisfy the given pattern.
-     * @param x  string expression
-     * @param pattern  string 
-     * @param escapeChar  escape character expression
-     * @return like predicate
-     */
-    Predicate notLike(Expression<String> x, String pattern, Expression<Character> escapeChar);
-	
-   /**
-     * Create a predicate for testing whether the expression
-     * does not satisfy the given pattern.
-     * @param x  string expression
-     * @param pattern  string 
-     * @param escapeChar  escape character
-     * @return like predicate
-     */
-    Predicate notLike(Expression<String> x, String pattern, char escapeChar);
+	/**
+	 * Create an expression that returns the difference
+	 * between its arguments.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return difference
+	 */
+	<N extends Number> Expression<N> diff(Expression<? extends N> x, Expression<? extends N> y);
 
-    /**
-     *  String concatenation operation.
-     *  @param x  string expression
-     *  @param y  string expression
-     *  @return expression corresponding to concatenation
-     */
-    Expression<String> concat(Expression<String> x, Expression<String> y);
-	
-    /**
-     *  String concatenation operation.
-     *  @param x  string expression
-     *  @param y  string 
-     *  @return expression corresponding to concatenation
-     */
-    Expression<String> concat(Expression<String> x, String y);
+	/**
+	 * Create an expression that returns the sum
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return sum
+	 */
+	<N extends Number> Expression<N> sum(Expression<? extends N> x, N y);
 
-    /**
-     *  String concatenation operation.
-     *  @param x  string 
-     *  @param y  string expression
-     *  @return expression corresponding to concatenation
-     */	
-    Expression<String> concat(String x, Expression<String> y);
-	
-    /**
-     *  Substring extraction operation.
-     *  Extracts a substring starting at specified position through
-     *  to end of the string.
-     *  First position is 1.
-     *  @param x  string expression
-     *  @param from  start position expression 
-     *  @return expression corresponding to substring extraction
-     */	
-    Expression<String> substring(Expression<String> x, Expression<Integer> from);
-	
-    /**
-     *  Substring extraction operation.
-     *  Extracts a substring starting at specified position through
-     *  to end of the string.
-     *  First position is 1.
-     *  @param x  string expression
-     *  @param from  start position 
-     *  @return expression corresponding to substring extraction
-     */	
-    Expression<String> substring(Expression<String> x, int from);
+	/**
+	 * Create an expression that returns the product
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return product
+	 */
+	<N extends Number> Expression<N> prod(Expression<? extends N> x, N y);
 
-    /**
-     *  Substring extraction operation.
-     *  Extracts a substring of given length starting at 
-     *  specified position.
-     *  First position is 1.
-     *  @param x  string expression
-     *  @param from  start position expression 
-     *  @param len  length expression
-     *  @return expression corresponding to substring extraction
-     */		
-    Expression<String> substring(Expression<String> x, Expression<Integer> from, Expression<Integer> len);
-	
-    /**
-     *  Substring extraction operation.
-     *  Extracts a substring of given length starting at 
-     *  specified position.
-     *  First position is 1.
-     *  @param x  string expression
-     *  @param from  start position 
-     *  @param len  length
-     *  @return expression corresponding to substring extraction
-     */		
-    Expression<String> substring(Expression<String> x, int from, int len);
-	
-    public static enum Trimspec { LEADING, TRAILING, BOTH }
-	
-    /**
-     * Create expression to trim blanks from both ends of
-     * a string.
-     * @param x  expression for string to trim
-     * @return trim expression
-     */
-    Expression<String> trim(Expression<String> x);
-	
-    /**
-     * Create expression to trim blanks from a string.
-     * @param ts  trim specification
-     * @param x  expression for string to trim
-     * @return trim expression
-     */
-    Expression<String> trim(Trimspec ts, Expression<String> x);
+	/**
+	 * Create an expression that returns the difference
+	 * between its arguments.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return difference
+	 */
+	<N extends Number> Expression<N> diff(Expression<? extends N> x, N y);
 
-    /**
-     * Create expression to trim character from both ends of
-     * a string.
-     * @param t  expression for character to be trimmed
-     * @param x  expression for string to trim
-     * @return trim expression
-     */
-    Expression<String> trim(Expression<Character> t, Expression<String> x);
+	/**
+	 * Create an expression that returns the sum
+	 * of its arguments.
+	 *
+	 * @param x value
+	 * @param y expression
+	 *
+	 * @return sum
+	 */
+	<N extends Number> Expression<N> sum(N x, Expression<? extends N> y);
 
-    /**
-     * Create expression to trim character from a string.
-     * @param ts  trim specification
-     * @param t  expression for character to be trimmed
-     * @param x  expression for string to trim
-     * @return trim expression
-     */
-    Expression<String> trim(Trimspec ts, Expression<Character> t, Expression<String> x);
-	
-    /**
-     * Create expression to trim character from both ends of
-     * a string.
-     * @param t  character to be trimmed
-     * @param x  expression for string to trim
-     * @return trim expression
-     */
-    Expression<String> trim(char t, Expression<String> x);
-	
-    /**
-     * Create expression to trim character from a string.
-     * @param ts  trim specification
-     * @param t  character to be trimmed
-     * @param x  expression for string to trim
-     * @return trim expression
-     */
-    Expression<String> trim(Trimspec ts, char t, Expression<String> x);
-	
-    /**
-     * Create expression for lowercasing a string.
-     * @param x  string expression
-     * @return expression to convert to lowercase
-     */
-    Expression<String> lower(Expression<String> x);
-	
-    /**
-     * Create expression for uppercasing a string.
-     * @param x  string expression
-     * @return expression to convert to uppercase
-     */
-    Expression<String> upper(Expression<String> x);
-	
-    /**
-     * Create expression to return length of a string.
-     * @param x  string expression
-     * @return length expression
-     */
-    Expression<Integer> length(Expression<String> x);
-	
-	
-    /**
-     * Create expression to locate the position of one string
-     * within another, returning position of first character
-     * if found.
-     * The first position in a string is denoted by 1.  If the
-     * string to be located is not found, 0 is returned.
-     * @param x  string to be search
-     * @param pattern  string to be located
-     * @return expression corresponding to position
-     */
-    Expression<Integer> locate(Expression<String> x, Expression<String> pattern);
+	/**
+	 * Create an expression that returns the product
+	 * of its arguments.
+	 *
+	 * @param x value
+	 * @param y expression
+	 *
+	 * @return product
+	 */
+	<N extends Number> Expression<N> prod(N x, Expression<? extends N> y);
 
-    /**
-     * Create expression to locate the position of one string
-     * within another, returning position of first character
-     * if found.
-     * The first position in a string is denoted by 1.  If the
-     * string to be located is not found, 0 is returned.
-     * @param x  string to be search
-     * @param pattern  string to be located
-     * @param from  position at which to start search
-     * @return expression corresponding to position
-     */	
-    Expression<Integer> locate(Expression<String> x, Expression<String> pattern, Expression<Integer> from);
-	
-    /**
-     * Create expression to locate the position of one string
-     * within another, returning position of first character
-     * if found.
-     * The first position in a string is denoted by 1.  If the
-     * string to be located is not found, 0 is returned.
-     * @param x  string to be search
-     * @param pattern  string to be located
-     * @return expression corresponding to position
-     */
-    Expression<Integer> locate(Expression<String> x, String pattern);
+	/**
+	 * Create an expression that returns the difference
+	 * between its arguments.
+	 *
+	 * @param x value
+	 * @param y expression
+	 *
+	 * @return difference
+	 */
+	<N extends Number> Expression<N> diff(N x, Expression<? extends N> y);
 
-    /**
-     * Create expression to locate the position of one string
-     * within another, returning position of first character
-     * if found.
-     * The first position in a string is denoted by 1.  If the
-     * string to be located is not found, 0 is returned.
-     * @param x  string to be search
-     * @param pattern  string to be located
-     * @param from  position at which to start search
-     * @return expression corresponding to position
-     */	
-    Expression<Integer> locate(Expression<String> x, String pattern, int from);
-	
+	/**
+	 * Create an expression that returns the quotient
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return quotient
+	 */
+	Expression<Number> quot(Expression<? extends Number> x, Expression<? extends Number> y);
 
-    // Date/time/timestamp functions:
+	/**
+	 * Create an expression that returns the quotient
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return quotient
+	 */
+	Expression<Number> quot(Expression<? extends Number> x, Number y);
 
-    /**
-     *  Create expression to return current date
-     *  @return expression for current date
-     */
-    Expression<java.sql.Date> currentDate();
+	/**
+	 * Create an expression that returns the quotient
+	 * of its arguments.
+	 *
+	 * @param x value
+	 * @param y expression
+	 *
+	 * @return quotient
+	 */
+	Expression<Number> quot(Number x, Expression<? extends Number> y);
 
-    /**
-     *  Create expression to return current timestamp
-     *  @return expression for current timestamp
-     */	
-    Expression<java.sql.Timestamp> currentTimestamp();
+	/**
+	 * Create an expression that returns the modulus
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return modulus
+	 */
+	Expression<Integer> mod(Expression<Integer> x, Expression<Integer> y);
 
-    /**
-     *  Create expression to return current time
-     *  @return expression for current time
-     */	
-    Expression<java.sql.Time> currentTime();
-	
+	/**
+	 * Create an expression that returns the modulus
+	 * of its arguments.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return modulus
+	 */
+	Expression<Integer> mod(Expression<Integer> x, Integer y);
 
-    //in builders:
-	
-    /**
-     *  Interface used to build in-expressions.
-     */
-    public static interface In<T> extends Predicate {
+	/**
+	 * Create an expression that returns the modulus
+	 * of its arguments.
+	 *
+	 * @param x value
+	 * @param y expression
+	 *
+	 * @return modulus
+	 */
+	Expression<Integer> mod(Integer x, Expression<Integer> y);
 
+	/**
+	 * Create an expression that returns the square root
+	 * of its argument.
+	 *
+	 * @param x expression
+	 *
+	 * @return square root
+	 */
+	Expression<Double> sqrt(Expression<? extends Number> x);
+
+
+	//typecasts:
+
+	/**
+	 * Typecast.
+	 *
+	 * @param number numeric expression
+	 *
+	 * @return Expression<Long>
+	 */
+	Expression<Long> toLong(Expression<? extends Number> number);
+
+	/**
+	 * Typecast.
+	 *
+	 * @param number numeric expression
+	 *
+	 * @return Expression<Integer>
+	 */
+	Expression<Integer> toInteger(Expression<? extends Number> number);
+
+	/**
+	 * Typecast.
+	 *
+	 * @param number numeric expression
+	 *
+	 * @return Expression<Float>
+	 */
+	Expression<Float> toFloat(Expression<? extends Number> number);
+
+	/**
+	 * Typecast.
+	 *
+	 * @param number numeric expression
+	 *
+	 * @return Expression<Double>
+	 */
+	Expression<Double> toDouble(Expression<? extends Number> number);
+
+	/**
+	 * Typecast.
+	 *
+	 * @param number numeric expression
+	 *
+	 * @return Expression<BigDecimal>
+	 */
+	Expression<BigDecimal> toBigDecimal(Expression<? extends Number> number);
+
+	/**
+	 * Typecast.
+	 *
+	 * @param number numeric expression
+	 *
+	 * @return Expression<BigInteger>
+	 */
+	Expression<BigInteger> toBigInteger(Expression<? extends Number> number);
+
+	/**
+	 * Typecast.
+	 *
+	 * @param character expression
+	 *
+	 * @return Expression<String>
+	 */
+	Expression<String> toString(Expression<Character> character);
+
+
+	//literals:
+
+	/**
+	 * Create an expression literal.
+	 *
+	 * @param value
+	 *
+	 * @return expression literal
+	 */
+	<T> Expression<T> literal(T value);
+
+
+	//parameters:
+
+	/**
+	 * Create a parameter expression.
+	 *
+	 * @param paramClass parameter class
+	 *
+	 * @return parameter expression
+	 */
+	<T> ParameterExpression<T> parameter(Class<T> paramClass);
+
+	/**
+	 * Create a parameter expression with the given name.
+	 *
+	 * @param paramClass parameter class
+	 * @param name
+	 *
+	 * @return parameter expression
+	 */
+	<T> ParameterExpression<T> parameter(Class<T> paramClass, String name);
+
+	//collection operations:
+
+	/**
+	 * Create a predicate that tests whether a collection is empty.
+	 *
+	 * @param collection expression
+	 *
+	 * @return predicate
+	 */
+	<C extends Collection<?>> Predicate isEmpty(Expression<C> collection);
+
+	/**
+	 * Create a predicate that tests whether a collection is
+	 * not empty.
+	 *
+	 * @param collection expression
+	 *
+	 * @return predicate
+	 */
+	<C extends Collection<?>> Predicate isNotEmpty(Expression<C> collection);
+
+	/**
+	 * Create an expression that tests the size of a collection.
+	 *
+	 * @param collection
+	 *
+	 * @return size expression
+	 */
+	<C extends Collection<?>> Expression<Integer> size(C collection);
+
+	/**
+	 * Create an expression that tests the size of a collection.
+	 *
+	 * @param collection expression
+	 *
+	 * @return size expression
+	 */
+	<C extends java.util.Collection<?>> Expression<Integer> size(Expression<C> collection);
+
+	/**
+	 * Create a predicate that tests whether an element is
+	 * a member of a collection.
+	 *
+	 * @param elem element
+	 * @param collection expression
+	 *
+	 * @return predicate
+	 */
+	<E, C extends Collection<E>> Predicate isMember(E elem, Expression<C> collection);
+
+	/**
+	 * Create a predicate that tests whether an element is
+	 * not a member of a collection.
+	 *
+	 * @param elem element
+	 * @param collection expression
+	 *
+	 * @return predicate
+	 */
+	<E, C extends Collection<E>> Predicate isNotMember(E elem, Expression<C> collection);
+
+	/**
+	 * Create a predicate that tests whether an element is
+	 * a member of a collection.
+	 *
+	 * @param elem element expression
+	 * @param collection expression
+	 *
+	 * @return predicate
+	 */
+	<E, C extends Collection<E>> Predicate isMember(Expression<E> elem, Expression<C> collection);
+
+	/**
+	 * Create a predicate that tests whether an element is
+	 * not a member of a collection.
+	 *
+	 * @param elem element expression
+	 * @param collection expression
+	 *
+	 * @return predicate
+	 */
+	<E, C extends Collection<E>> Predicate isNotMember(Expression<E> elem, Expression<C> collection);
+
+
+	//get the values and keys collections of the Map, which may then
+	//be passed to size(), isMember(), isEmpty(), etc
+
+	/**
+	 * Create an expression that returns the values of a map.
+	 *
+	 * @param map
+	 *
+	 * @return collection expression
+	 */
+	<V, M extends Map<?, V>> Expression<Collection<V>> values(M map);
+
+	/**
+	 * Create an expression that returns the keys of a map.
+	 *
+	 * @param map
+	 *
+	 * @return set expression
+	 */
+	<K, M extends Map<K, ?>> Expression<Set<K>> keys(M map);
+
+
+	//string functions:
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * satisfies the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string expression
+	 *
+	 * @return like predicate
+	 */
+	Predicate like(Expression<String> x, Expression<String> pattern);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * satisfies the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string expression
+	 * @param escapeChar escape character expression
+	 *
+	 * @return like predicate
+	 */
+	Predicate like(Expression<String> x, Expression<String> pattern, Expression<Character> escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * satisfies the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string expression
+	 * @param escapeChar escape character
+	 *
+	 * @return like predicate
+	 */
+	Predicate like(Expression<String> x, Expression<String> pattern, char escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * satisfies the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string
+	 *
+	 * @return like predicate
+	 */
+	Predicate like(Expression<String> x, String pattern);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * satisfies the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string
+	 * @param escapeChar escape character expression
+	 *
+	 * @return like predicate
+	 */
+	Predicate like(Expression<String> x, String pattern, Expression<Character> escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * satisfies the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string
+	 * @param escapeChar escape character
+	 *
+	 * @return like predicate
+	 */
+	Predicate like(Expression<String> x, String pattern, char escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * does not satisfy the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string expression
+	 *
+	 * @return like predicate
+	 */
+	Predicate notLike(Expression<String> x, Expression<String> pattern);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * does not satisfy the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string expression
+	 * @param escapeChar escape character expression
+	 *
+	 * @return like predicate
+	 */
+	Predicate notLike(Expression<String> x, Expression<String> pattern, Expression<Character> escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * does not satisfy the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string expression
+	 * @param escapeChar escape character
+	 *
+	 * @return like predicate
+	 */
+	Predicate notLike(Expression<String> x, Expression<String> pattern, char escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * does not satisfy the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string
+	 *
+	 * @return like predicate
+	 */
+	Predicate notLike(Expression<String> x, String pattern);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * does not satisfy the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string
+	 * @param escapeChar escape character expression
+	 *
+	 * @return like predicate
+	 */
+	Predicate notLike(Expression<String> x, String pattern, Expression<Character> escapeChar);
+
+	/**
+	 * Create a predicate for testing whether the expression
+	 * does not satisfy the given pattern.
+	 *
+	 * @param x string expression
+	 * @param pattern string
+	 * @param escapeChar escape character
+	 *
+	 * @return like predicate
+	 */
+	Predicate notLike(Expression<String> x, String pattern, char escapeChar);
+
+	/**
+	 * String concatenation operation.
+	 *
+	 * @param x string expression
+	 * @param y string expression
+	 *
+	 * @return expression corresponding to concatenation
+	 */
+	Expression<String> concat(Expression<String> x, Expression<String> y);
+
+	/**
+	 * String concatenation operation.
+	 *
+	 * @param x string expression
+	 * @param y string
+	 *
+	 * @return expression corresponding to concatenation
+	 */
+	Expression<String> concat(Expression<String> x, String y);
+
+	/**
+	 * String concatenation operation.
+	 *
+	 * @param x string
+	 * @param y string expression
+	 *
+	 * @return expression corresponding to concatenation
+	 */
+	Expression<String> concat(String x, Expression<String> y);
+
+	/**
+	 * Substring extraction operation.
+	 * Extracts a substring starting at specified position through
+	 * to end of the string.
+	 * First position is 1.
+	 *
+	 * @param x string expression
+	 * @param from start position expression
+	 *
+	 * @return expression corresponding to substring extraction
+	 */
+	Expression<String> substring(Expression<String> x, Expression<Integer> from);
+
+	/**
+	 * Substring extraction operation.
+	 * Extracts a substring starting at specified position through
+	 * to end of the string.
+	 * First position is 1.
+	 *
+	 * @param x string expression
+	 * @param from start position
+	 *
+	 * @return expression corresponding to substring extraction
+	 */
+	Expression<String> substring(Expression<String> x, int from);
+
+	/**
+	 * Substring extraction operation.
+	 * Extracts a substring of given length starting at
+	 * specified position.
+	 * First position is 1.
+	 *
+	 * @param x string expression
+	 * @param from start position expression
+	 * @param len length expression
+	 *
+	 * @return expression corresponding to substring extraction
+	 */
+	Expression<String> substring(Expression<String> x, Expression<Integer> from, Expression<Integer> len);
+
+	/**
+	 * Substring extraction operation.
+	 * Extracts a substring of given length starting at
+	 * specified position.
+	 * First position is 1.
+	 *
+	 * @param x string expression
+	 * @param from start position
+	 * @param len length
+	 *
+	 * @return expression corresponding to substring extraction
+	 */
+	Expression<String> substring(Expression<String> x, int from, int len);
+
+	public static enum Trimspec {
+		LEADING, TRAILING, BOTH
+	}
+
+	/**
+	 * Create expression to trim blanks from both ends of
+	 * a string.
+	 *
+	 * @param x expression for string to trim
+	 *
+	 * @return trim expression
+	 */
+	Expression<String> trim(Expression<String> x);
+
+	/**
+	 * Create expression to trim blanks from a string.
+	 *
+	 * @param ts trim specification
+	 * @param x expression for string to trim
+	 *
+	 * @return trim expression
+	 */
+	Expression<String> trim(Trimspec ts, Expression<String> x);
+
+	/**
+	 * Create expression to trim character from both ends of
+	 * a string.
+	 *
+	 * @param t expression for character to be trimmed
+	 * @param x expression for string to trim
+	 *
+	 * @return trim expression
+	 */
+	Expression<String> trim(Expression<Character> t, Expression<String> x);
+
+	/**
+	 * Create expression to trim character from a string.
+	 *
+	 * @param ts trim specification
+	 * @param t expression for character to be trimmed
+	 * @param x expression for string to trim
+	 *
+	 * @return trim expression
+	 */
+	Expression<String> trim(Trimspec ts, Expression<Character> t, Expression<String> x);
+
+	/**
+	 * Create expression to trim character from both ends of
+	 * a string.
+	 *
+	 * @param t character to be trimmed
+	 * @param x expression for string to trim
+	 *
+	 * @return trim expression
+	 */
+	Expression<String> trim(char t, Expression<String> x);
+
+	/**
+	 * Create expression to trim character from a string.
+	 *
+	 * @param ts trim specification
+	 * @param t character to be trimmed
+	 * @param x expression for string to trim
+	 *
+	 * @return trim expression
+	 */
+	Expression<String> trim(Trimspec ts, char t, Expression<String> x);
+
+	/**
+	 * Create expression for converting a string to lowercase.
+	 *
+	 * @param x string expression
+	 *
+	 * @return expression to convert to lowercase
+	 */
+	Expression<String> lower(Expression<String> x);
+
+	/**
+	 * Create expression for converting a string to uppercase.
+	 *
+	 * @param x string expression
+	 *
+	 * @return expression to convert to uppercase
+	 */
+	Expression<String> upper(Expression<String> x);
+
+	/**
+	 * Create expression to return length of a string.
+	 *
+	 * @param x string expression
+	 *
+	 * @return length expression
+	 */
+	Expression<Integer> length(Expression<String> x);
+
+
+	/**
+	 * Create expression to locate the position of one string
+	 * within another, returning position of first character
+	 * if found.
+	 * The first position in a string is denoted by 1.  If the
+	 * string to be located is not found, 0 is returned.
+	 *
+	 * @param x expression for string to be searched
+	 * @param pattern expression for string to be located
+	 *
+	 * @return expression corresponding to position
+	 */
+	Expression<Integer> locate(Expression<String> x, Expression<String> pattern);
+
+	/**
+	 * Create expression to locate the position of one string
+	 * within another, returning position of first character
+	 * if found.
+	 * The first position in a string is denoted by 1.  If the
+	 * string to be located is not found, 0 is returned.
+	 *
+	 * @param x expression for string to be searched
+	 * @param pattern expression for string to be located
+	 * @param from expression for position at which to start search
+	 *
+	 * @return expression corresponding to position
+	 */
+	Expression<Integer> locate(Expression<String> x, Expression<String> pattern, Expression<Integer> from);
+
+	/**
+	 * Create expression to locate the position of one string
+	 * within another, returning position of first character
+	 * if found.
+	 * The first position in a string is denoted by 1.  If the
+	 * string to be located is not found, 0 is returned.
+	 *
+	 * @param x expression for string to be searched
+	 * @param pattern string to be located
+	 *
+	 * @return expression corresponding to position
+	 */
+	Expression<Integer> locate(Expression<String> x, String pattern);
+
+	/**
+	 * Create expression to locate the position of one string
+	 * within another, returning position of first character
+	 * if found.
+	 * The first position in a string is denoted by 1.  If the
+	 * string to be located is not found, 0 is returned.
+	 *
+	 * @param x expression for string to be searched
+	 * @param pattern string to be located
+	 * @param from position at which to start search
+	 *
+	 * @return expression corresponding to position
+	 */
+	Expression<Integer> locate(Expression<String> x, String pattern, int from);
+
+
+	// Date/time/timestamp functions:
+
+	/**
+	 * Create expression to return current date.
+	 *
+	 * @return expression for current date
+	 */
+	Expression<java.sql.Date> currentDate();
+
+	/**
+	 * Create expression to return current timestamp.
+	 *
+	 * @return expression for current timestamp
+	 */
+	Expression<java.sql.Timestamp> currentTimestamp();
+
+	/**
+	 * Create expression to return current time.
+	 *
+	 * @return expression for current time
+	 */
+	Expression<java.sql.Time> currentTime();
+
+
+	//in builders:
+
+	/**
+	 * Interface used to build in-expressions.
+	 */
+	public static interface In<T> extends Predicate {
+
 		/**
 		 * Returns the expression to be tested against the
 		 * list of values.
+		 *
 		 * @return expression
 		 */
 		Expression<T> getExpression();
-	
+
 		/**
-		 *  Add to list of values to be tested against.
-		 *  @param value
-		 *  @return in predicate
+		 * Add to list of values to be tested against.
+		 *
+		 * @param value
+		 *
+		 * @return in predicate
 		 */
 		In<T> value(T value);
 
 		/**
-		 *  Add to list of values to be tested against.
-		 *  @param value expression
-		 *  @return in predicate
+		 * Add to list of values to be tested against.
+		 *
+		 * @param value expression
+		 *
+		 * @return in predicate
 		 */
 		In<T> value(Expression<? extends T> value);
 	}
-	
-    /**
-     *  Create predicate to test whether given expression
-     *  is contained in a list of values.
-     *  @param  expression
-     *  @return  in predicate
-     */
-    <T> In<T> in(Expression<? extends T> expression);
-	
 
-    //coalesce, nullif:
-	
-    /**
-     * Create an expression that returns null if all its arguments
-     * evaluate to null, and the value of the first non-null argument
-     * otherwise.
-     * @param x expression
-     * @param y expression
-     * @return expression corresponding to the given coalesce 
-     * 				expression
-     */
-    <Y> Expression<Y> coalesce(Expression<? extends Y> x, Expression<? extends Y> y);
+	/**
+	 * Create predicate to test whether given expression
+	 * is contained in a list of values.
+	 *
+	 * @param expression to be tested against list of values
+	 *
+	 * @return in predicate
+	 */
+	<T> In<T> in(Expression<? extends T> expression);
 
-    /**
-     * Create an expression that returns null if all its arguments
-     * evaluate to null, and the value of the first non-null argument
-     * otherwise.
-     * @param x expression
-     * @param y value
-     * @return coalesce expression
-     */
-    <Y> Expression<Y> coalesce(Expression<? extends Y> x, Y y);
-    
-    /**
-     * Create an expression that tests whether its argument are
-     * equal, returning null if they are and the value of the
-     * first expression if they are not.
-     * @param x expression
-     * @param y expression
-     * @return expression corresponding to the given nullif 
-     * 				expression
-     */
-    <Y> Expression<Y> nullif(Expression<Y> x, Expression<?> y);
 
-    
-    /**
-     * Create an expression that tests whether its argument are
-     * equal, returning null if they are and the value of the
-     * first expression if they are not.
-     * @param x expression
-     * @param y value
-     * @return expression corresponding to the given nullif 
-     * 				expression
-     */
-    <Y> Expression<Y> nullif(Expression<Y> x, Object y);
+	//coalesce, nullif:
 
+	/**
+	 * Create an expression that returns null if all its arguments
+	 * evaluate to null, and the value of the first non-null argument
+	 * otherwise.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return expression corresponding to the given coalesce
+	 *         expression
+	 */
+	<Y> Expression<Y> coalesce(Expression<? extends Y> x, Expression<? extends Y> y);
 
-    // coalesce builder:
+	/**
+	 * Create an expression that returns null if all its arguments
+	 * evaluate to null, and the value of the first non-null argument
+	 * otherwise.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return coalesce expression
+	 */
+	<Y> Expression<Y> coalesce(Expression<? extends Y> x, Y y);
 
-    /**
-     *  Interface used to build coalesce expressions
-     */
-    public static interface Coalesce<T> extends Expression<T> {
+	/**
+	 * Create an expression that tests whether its argument are
+	 * equal, returning null if they are and the value of the
+	 * first expression if they are not.
+	 *
+	 * @param x expression
+	 * @param y expression
+	 *
+	 * @return expression corresponding to the given nullif
+	 *         expression
+	 */
+	<Y> Expression<Y> nullif(Expression<Y> x, Expression<?> y);
 
+
+	/**
+	 * Create an expression that tests whether its argument are
+	 * equal, returning null if they are and the value of the
+	 * first expression if they are not.
+	 *
+	 * @param x expression
+	 * @param y value
+	 *
+	 * @return expression corresponding to the given nullif
+	 *         expression
+	 */
+	<Y> Expression<Y> nullif(Expression<Y> x, Y y);
+
+
+	// coalesce builder:
+
+	/**
+	 * Interface used to build coalesce expressions.
+	 * A coalesce expression is equivalent to a case expression
+	 * that returns null if all its arguments evaluate to null,
+	 * and the value of its first non-null argument otherwise.
+	 */
+	public static interface Coalesce<T> extends Expression<T> {
+
 		/**
 		 * Add an argument to the coalesce expression.
+		 *
 		 * @param value
+		 *
 		 * @return coalesce expression
 		 */
 		Coalesce<T> value(T value);
 
 		/**
 		 * Add an argument to the coalesce expression.
+		 *
 		 * @param value expression
+		 *
 		 * @return coalesce expression
 		 */
 		Coalesce<T> value(Expression<? extends T> value);
 	}
-	
-    /**
-     * Create a coalesce expression.
-     * A coalesce expression is equivalent to a case expression
-     * that returns null if all its arguments evaluate to null,
-     * and the value of its first non-null argument otherwise.
-     * @return coalesce expression
-     */
-    <T> Coalesce<T> coalesce();
 
+	/**
+	 * Create a coalesce expression.
+	 *
+	 * @return coalesce expression
+	 */
+	<T> Coalesce<T> coalesce();
 
-    //case builders:
 
-    /**
-     *  Interface used to build simple case expressions.
-     */
-    public static interface SimpleCase<C,R> extends Expression<R> {
+	//case builders:
 
+	/**
+	 * Interface used to build simple case expressions.
+	 */
+	public static interface SimpleCase<C, R> extends Expression<R> {
+
 		/**
 		 * Returns the expression to be tested against the
 		 * conditions.
+		 *
 		 * @return expression
 		 */
 		Expression<C> getExpression();
 
 		/**
 		 * Add a when/then clause to the case expression.
-		 * @param condition  "then" condition
-		 * @param result  "when" result
-		 * @result simple case expression
+		 *
+		 * @param condition "when" condition
+		 * @param result "then" result value
+		 *
+		 * @return simple case expression
 		 */
 		SimpleCase<C, R> when(C condition, R result);
 
 		/**
 		 * Add a when/then clause to the case expression.
-		 * @param condition  "then" condition
-		 * @param result  "when" result expression
-		 * @result simple case expression
+		 *
+		 * @param condition "when" condition
+		 * @param result "then" result expression
+		 *
+		 * @return simple case expression
 		 */
 		SimpleCase<C, R> when(C condition, Expression<? extends R> result);
 
 		/**
-		 * Add an else clause to the case expression.
-		 * @param result  "else" result
-		 * @result expression
+		 * Add an "else" clause to the case expression.
+		 *
+		 * @param result "else" result
+		 *
+		 * @return expression
 		 */
-		Expression<R> elseCase(R result);
+		Expression<R> otherwise(R result);
 
 		/**
-		 * Add an else clause to the case expression.
-		 * @param result  "else" result expression
-		 * @result expression
+		 * Add an "else" clause to the case expression.
+		 *
+		 * @param result "else" result expression
+		 *
+		 * @return expression
 		 */
-		Expression<R> elseCase(Expression<? extends R> result);
+		Expression<R> otherwise(Expression<? extends R> result);
 	}
-	
-    /**
-     *  Create simple case expression.
-     *  @param expression  to be tested against the cases
-     *  @return simple case expression
-     */
-    <C, R> SimpleCase<C,R> selectCase(Expression<? extends C> expression);
 
+	/**
+	 * Create simple case expression.
+	 *
+	 * @param expression to be tested against the case conditions
+	 *
+	 * @return simple case expression
+	 */
+	<C, R> SimpleCase<C, R> selectCase(Expression<? extends C> expression);
 
-    /**
-     *  Interface used to build general case expressions.
-     */
-    public static interface Case<R> extends Expression<R> {
 
+	/**
+	 * Interface used to build general case expressions.
+	 */
+	public static interface Case<R> extends Expression<R> {
+
 		/**
 		 * Add a when/then clause to the case expression.
-		 * @param condition  "then" condition
-		 * @param result  "when" result
-		 * @result general case expression
+		 *
+		 * @param condition "when" condition
+		 * @param result "then" result value
+		 *
+		 * @return general case expression
 		 */
 		Case<R> when(Expression<Boolean> condition, R result);
 
 		/**
 		 * Add a when/then clause to the case expression.
-		 * @param condition  "then" condition
-		 * @param result  "when" result expression
-		 * @result general case expression
+		 *
+		 * @param condition "when" condition
+		 * @param result "then" result expression
+		 *
+		 * @return general case expression
 		 */
 		Case<R> when(Expression<Boolean> condition, Expression<? extends R> result);
 
 		/**
-		 * Add an else clause to the case expression.
-		 * @param result  "else" result
-		 * @result expression
+		 * Add an "else" clause to the case expression.
+		 *
+		 * @param result "else" result
+		 *
+		 * @return expression
 		 */
-		Expression<R> elseCase(R result);
+		Expression<R> otherwise(R result);
 
 		/**
-		 * Add an else clause to the case expression.
-		 * @param result  "else" result expression
-		 * @result expression
+		 * Add an "else" clause to the case expression.
+		 *
+		 * @param result "else" result expression
+		 *
+		 * @return expression
 		 */
-		Expression<R> elseCase(Expression<? extends R> result);
+		Expression<R> otherwise(Expression<? extends R> result);
 	}
-	
-    /**
-     *  Create a general case expression.
-     *  @return general case expression
-     */
-    <R> Case<R> selectCase();
-}
 
+	/**
+	 * Create a general case expression.
+	 *
+	 * @return general case expression
+	 */
+	<R> Case<R> selectCase();
 
+	/**
+	 * Create an expression for execution of a database
+	 * function.
+	 *
+	 * @param name function name
+	 * @param type expected result type
+	 * @param args function arguments
+	 *
+	 * @return expression
+	 */
+	<T> Expression<T> function(String name, Class<T> type,
+							   Expression<?>... args);
 
-
+}
\ No newline at end of file

Deleted: jpa-api/trunk/src/main/java/javax/persistence/criteria/Result.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Result.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Result.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,14 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.criteria;
-
-public interface Result {
-
-    <X> X get(Selection<X> selection);
-
-    <X> X get(int i, Class<X> type);
-
-    Object get(int i);
-
-    Object[] toArray();
-}

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Root.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Root.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Root.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,8 +1,8 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.Entity;
+import javax.persistence.metamodel.EntityType;
 
 /**
  * A root type in the from clause.
@@ -16,5 +16,6 @@
      * Return the metamodel entity corresponding to the root.
      * @return metamodel entity corresponding to the root
      */
-    Entity<X> getModel();
+    EntityType<X> getModel();
 }
+

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Selection.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Selection.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Selection.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,18 +1,37 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
+import javax.persistence.TupleElement;
+import java.util.List;
+
 /**
- * The Selection interface defines an item that is returned by
- * a query.
- * @param <X>
+ * The Selection interface defines an item that to be
+ * returned in the query result.
+ * @param <X> the type of the selection item
  */
+public interface Selection<X> extends TupleElement<X> {
 
-public interface Selection<X> {
-    
     /**
-     * Return the Java type of the selection.
-     * @return the Java type of the selection item
+     * Return a selection item with the assigned alias.
+     * @param name  alias
+     * @return selection item
      */
-    Class<?> getJavaType();
+    Selection<X> alias(String name);
+
+    /**
+     * Whether the selection item is a compound selection
+     * @return boolean
+     */
+    boolean isCompoundSelection();
+
+    /**
+     * Return selection items composing a compound selection
+     * @return list of selection items
+     * @throws IllegalStateException if selection is not a compound
+     *           selection
+     */
+    List<Selection<?>> getCompoundSelectionItems();
+
 }
+

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/SetJoin.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/SetJoin.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/SetJoin.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,25 +1,24 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
 import java.util.Set;
+import javax.persistence.metamodel.SetAttribute;
 
 /**
- * The interface SetJoin is the type of the result of
- * joining to a collection over an association or element 
+ * The SetJoin interface is the type of the result of
+ * joining to a collection over an association or element
  * collection that has been specified as a java.util.Set.
  *
  * @param <Z> The source type of the join
- * @param <E> The element type of the target Set 
+ * @param <E> The element type of the target Set
  */
+public interface SetJoin<Z, E> extends PluralJoin<Z, Set<E>, E> {
 
-public interface SetJoin<Z, E> 
-		extends AbstractCollectionJoin<Z, Set<E>, E> {
-
     /**
-     * Return the metamodel representation for the set.
+     * Return the metamodel representation for the set attribute.
      * @return metamodel type representing the Set that is
      *         the target of the join
      */
-    javax.persistence.metamodel.Set<? super Z, E> getModel();
+    SetAttribute<? super Z, E> getModel();
 }

Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/Subquery.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/Subquery.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/Subquery.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,44 +1,36 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.criteria;
 
-import javax.persistence.metamodel.Collection;
-import javax.persistence.metamodel.List;
-import javax.persistence.metamodel.Map;
-import javax.persistence.metamodel.Set;
-
 /**
- * The interface Subquery defines functionality that is 
+ * The Subquery interface defines functionality that is
  * specific to subqueries.
  *
  * A subquery has an expression as its selection item.
  * @param <T> the type of the returned selection item.
  */
+public interface Subquery<T> extends AbstractQuery<T>, Expression<T> {
 
-public interface Subquery<T> extends AbstractQuery, Expression<T> {
-
     /**
-     * Return the query of which this is a subquery
+     * Return the query of which this is a subquery.
      * @return the enclosing query or subquery
      */
-    AbstractQuery getParent();
-	
+    AbstractQuery<?> getParent();
+
     /**
      * Specify the item that is to be returned in the query result.
      * Replaces the previously specified selection, if any.
-     * @param expression  expressions specifying the item that
+     * @param expression  expression specifying the item that
      *        is returned in the query result
      * @return the modified subquery
      */
     Subquery<T> select(Expression<T> expression);
-	
-    //override the return type only:
 
     /**
      * Modify the subquery to restrict the result according
      * to the specified boolean expression.
      * Replaces the previously added restriction(s), if any.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restriction  a simple or compound boolean expression
      * @return the modified subquery
@@ -46,12 +38,12 @@
     Subquery<T> where(Expression<Boolean> restriction);
 
     /**
-     * Modify the subquery to restrict the result according 
+     * Modify the subquery to restrict the result according
      * to the conjunction of the specified restriction predicates.
      * Replaces the previously added restriction(s), if any.
      * If no restrictions are specified, any previously added
      * restrictions are simply removed.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restrictions  zero or more restriction predicates
      * @return the modified subquery
@@ -62,19 +54,19 @@
      * Specify the expressions that are used to form groups over
      * the subquery results.
      * Replaces the previous specified grouping expressions, if any.
-     * If no grouping expressions are specified, any previously 
+     * If no grouping expressions are specified, any previously
      * added grouping expressions are simply removed.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param grouping  zero or more grouping expressions
      * @return the modified subquery
      */
-    Subquery<T> group(Expression<?>... grouping);
+    Subquery<T> groupBy(Expression<?>... grouping);
 
     /**
      * Specify a restriction over the groups of the subquery.
      * Replaces the previous having restriction(s), if any.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restriction  a simple or compound boolean expression
      * @return the modified subquery
@@ -83,42 +75,25 @@
 
     /**
      * Specify restrictions over the groups of the subquery
-     * according the conjunction of the specified restriction 
+     * according the conjunction of the specified restriction
      * predicates.
      * Replaces the previously added restriction(s), if any.
      * If no restrictions are specified, any previously added
      * restrictions are simply removed.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param restrictions  zero or more restriction predicates
      * @return the modified subquery
      */
-    Subquery having(Predicate... restrictions);
+    Subquery<T> having(Predicate... restrictions);
 
     /**
-     * Specify the ordering expressions that are used to
-     * order the subquery results.
-     * Replaces the previous ordering expressions, if any.
-     * If no ordering expressions are specified, the previous
-     * ordering, if any, is simply removed, and results will
-     * be returned in no particular order.
-     * The left-to-right sequence of the ordering expressions
-     * determines the precedence, whereby the leftmost has highest
-     * precedence.
-     * This method only overrides the return type of the 
-     * corresponding AbstractQuery method.
-     * @param o  zero or more ordering expressions
-     * @return the modified subquery.
-     */
-    Subquery<T> order(Order... o);
-
-    /**
      * Specify whether duplicate query results will be eliminated.
      * A true value will cause duplicates to be eliminated.
      * A false value will cause duplicates to be retained.
      * If distinct has not been specified, duplicate results must
      * be retained.
-     * This method only overrides the return type of the 
+     * This method only overrides the return type of the
      * corresponding AbstractQuery method.
      * @param distinct  boolean value specifying whether duplicate
      *        results must be eliminated from the subquery result or
@@ -126,62 +101,69 @@
      * @return the modified subquery.
      */
     Subquery<T> distinct(boolean distinct);
-	
+
     /**
-     * Return the selection expression
+     * Return the selection expression.
      * @return the item to be returned in the subquery result
      */
     Expression<T> getSelection();
-	
+
     /**
-     * Correlates a root of the enclosing query to a root of
-     * the subquery and returns the subquery root.
+     * Correlate a root of the enclosing query to a root of
+     * the subquery and return the subquery root.
      * @param parentRoot  a root of the containing query
      * @return subquery root
      */
     <Y> Root<Y> correlate(Root<Y> parentRoot);
 
     /**
-     * Correlates a join of the enclosing query to a join of
-     * the subquery and returns the subquery join.
+     * Correlate a join of the enclosing query to a join of
+     * the subquery and return the subquery join.
      * @param parentJoin  join target of the containing query
      * @return subquery join
      */
     <X, Y> Join<X, Y> correlate(Join<X, Y> parentJoin);
 
     /**
-     * Correlates a join to a Collection-valued association or
+     * Correlate a join to a Collection-valued association or
      * element collection in the enclosing query to a join of
-     * the subquery and returns the subquery join.
+     * the subquery and return the subquery join.
      * @param parentCollection  join target of the containing query
      * @return subquery join
      */
     <X, Y> CollectionJoin<X, Y> correlate(CollectionJoin<X, Y> parentCollection);
 
     /**
-     * Correlates a join to a Set-valued association or
+     * Correlate a join to a Set-valued association or
      * element collection in the enclosing query to a join of
-     * the subquery and returns the subquery join.
+     * the subquery and return the subquery join.
      * @param parentSet  join target of the containing query
      * @return subquery join
      */
     <X, Y> SetJoin<X, Y> correlate(SetJoin<X, Y> parentSet);
 
     /**
-     * Correlates a join to a List-valued association or
+     * Correlate a join to a List-valued association or
      * element collection in the enclosing query to a join of
-     * the subquery and returns the subquery join.
+     * the subquery and return the subquery join.
      * @param parentList  join target of the containing query
      * @return subquery join
      */
     <X, Y> ListJoin<X, Y> correlate(ListJoin<X, Y> parentList);
 
     /**
-     * Correlates a join to a Map-valued association or
+     * Correlate a join to a Map-valued association or
      * element collection in the enclosing query to a join of
-     * the subquery and returns the subquery join.
+     * the subquery and return the subquery join.
      * @param parentMap  join target of the containing query
      * @return subquery join
      */
     <X, K, V> MapJoin<X, K, V> correlate(MapJoin<X, K, V> parentMap);
-}
+
+    /**
+     *  Return the joins that have been made from the subquery.
+     *  @return joins made from this type
+     */
+    java.util.Set<Join<?, ?>> getJoins();
+
+}
\ No newline at end of file

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/AbstractCollection.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/AbstractCollection.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/AbstractCollection.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,42 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * Instances of the type AbstractionCollection represent persistent
- * collection-valued attributes.
- *
- * @param <X> The type the represented collection belongs to
- * @param <C> The type of the represented collection
- * @param <E> The element type of the represented collection
- */
-public interface AbstractCollection<X, C, E> 
-		extends Member<X, C>, Bindable<E> {
-	
-	public static enum CollectionType {
-		COLLECTION, SET, LIST, MAP
-	}
-	
-	public static enum Multiplicity {
-		MANY_TO_MANY, ONE_TO_MANY, ELEMENT_COLLECTION
-	}
-	
-    /**
-     * Return the collection type
-     * @return collection type
-     */
-    CollectionType getCollectionType();
-
-    /**
-     * Return the multiplicity
-     * @return multiplicity
-     */
-    Multiplicity getMultiplicity();
-
-    /**
-     * Return the type representing the element type of the 
-     * collection.
-     * @return element type
-     */
-    Type<E> getElementType();
-}

Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Attribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Attribute.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Attribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,49 +1,70 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.metamodel;
 
 /**
- * Instances of the type Attribute represents persistent 
- * non-collection-valued properties or fields.
+ * An attribute of a Java type
  *
- * @param <X> The represented type containing the attribute
- * @param <T> The type of the represented attribute
+ * @param <X> The represented type that contains the attribute
+ * @param <Y> The type of the represented attribute
  */
-public interface Attribute<X, T> 
-		extends Member<X, T>, Bindable<T> {
-	
-	public static enum Multiplicity {
-		MANY_TO_ONE, ONE_TO_ONE, EMBEDDED, BASIC
+public interface Attribute<X, Y> {
+
+	public static enum PersistentAttributeType {
+		MANY_TO_ONE, ONE_TO_ONE, BASIC, EMBEDDED,
+		MANY_TO_MANY, ONE_TO_MANY, ELEMENT_COLLECTION
 	}
-	
-    /**
-     *  Return the multiplicity of the attribute.
-     *  @return multiplicity
-     */
-    Multiplicity getMultiplicity();
 
-    /**
-     *  Is the attribute an id attribute.
-     *  @return boolean indicating whether or not an id
-     */
-    boolean isId();
+	/**
+	 * Return the name of the attribute.
+	 *
+	 * @return name
+	 */
+	String getName();
 
-    /**
-     *  Is the attribute a version attribute.
-     *  @return boolean indicating whether or not a version attribute
-     */
-    boolean isVersion();
+	/**
+	 * Return the persistent attribute type for the attribute.
+	 *
+	 * @return persistent attribute type
+	 */
+	PersistentAttributeType getPersistentAttributeType();
 
-    /** 
-     *  Can the attribute be null.
-     *  @return boolean indicating whether or not the attribute can
-     * 				be null
-     */
-    boolean isOptional();
+	/**
+	 * Return the managed type representing the type in which
+	 * the attribute was declared.
+	 *
+	 * @return declaring type
+	 */
+	ManagedType<X> getDeclaringType();
 
-    /**
-     * Return the type that represents the type of the attribute.
-     * @return type of attribute
-     */
-    Type<T> getAttributeType();
+	/**
+	 * Return the Java type of the represented attribute.
+	 *
+	 * @return Java type
+	 */
+	Class<Y> getJavaType();
+
+	/**
+	 * Return the java.lang.reflect.Member for the represented
+	 * attribute.
+	 *
+	 * @return corresponding java.lang.reflect.Member
+	 */
+	java.lang.reflect.Member getJavaMember();
+
+	/**
+	 * Is the attribute an association.
+	 *
+	 * @return whether boolean indicating whether attribute
+	 *         corresponds to an association
+	 */
+	boolean isAssociation();
+
+	/**
+	 * Is the attribute collection-valued.
+	 *
+	 * @return boolean indicating whether attribute is
+	 *         collection-valued
+	 */
+	boolean isCollection();
 }

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Basic.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Basic.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Basic.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,11 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * Instances of the type Basic represent basic types (including
- * temporal and enumerated types).
- *
- * @param <X> The type of the represented basic type
- */
-public interface Basic<X> extends Type<X> {}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/BasicType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/BasicType.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/BasicType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,12 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type BasicType represent basic types (including
+ * temporal and enumerated types).
+ *
+ * @param <X> The type of the represented basic type
+ */
+public interface BasicType<X> extends Type<X> {
+}

Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Bindable.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Bindable.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Bindable.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,28 +1,34 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.metamodel;
 
 /**
- * Instances of the type Bindable represent object or attribute types 
- * that can be bound into the from clause.
+ * Instances of the type Bindable represent object or attribute types
+ * that can be bound into a Path.
  *
  * @param <T>  The type of the represented object or attribute
  */
 public interface Bindable<T> {
-	
-	public static enum BindableType { 
-		ATTRIBUTE, COLLECTION, MANAGED_TYPE
+
+	public static enum BindableType {
+		SINGULAR_ATTRIBUTE, PLURAL_ATTRIBUTE, ENTITY_TYPE
 	}
 
-    /**
-     *  Return the bindable type of the represented object
-     *  @return bindable type
-     */	
-    BindableType getBindableType();
-	
-    /**
-     * Return the Java type of the represented object
-     * @return Java type
-     */
-    Class<T> getJavaType();
+	/**
+	 * Return the bindable type of the represented object.
+	 *
+	 * @return bindable type
+	 */
+	BindableType getBindableType();
+
+	/**
+	 * Return the Java type of the represented object.
+	 * If the bindable type of the object is PLURAL_ATTRIBUTE,
+	 * the Java element type is returned. If the bindable type is
+	 * SINGULAR_ATTRIBUTE or ENTITY_TYPE, the Java type of the
+	 * represented entity or attribute is returned.
+	 *
+	 * @return Java type
+	 */
+	Class<T> getBindableJavaType();
 }

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Collection.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Collection.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Collection.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,13 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * Instances of the type Collection represent persistent 
- * Collection-valued attributes.
- *
- * @param <X> The type the represented Collection belongs to
- * @param <E> The element type of the represented Collection
- */
-public interface Collection<X, E> 
-		extends AbstractCollection<X, java.util.Collection<E>, E> {}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/CollectionAttribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/CollectionAttribute.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/CollectionAttribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,15 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type CollectionAttribute represent persistent
+ * Collection-valued attributes.
+ *
+ * @param <X> The type the represented Collection belongs to
+ * @param <E> The element type of the represented Collection
+ */
+public interface CollectionAttribute<X, E>
+		extends PluralAttribute<X, java.util.Collection<E>, E> {
+}
+

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Embeddable.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Embeddable.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Embeddable.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,10 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- *  Instances of the type Embeddable represent embeddable types.
- *
- *  @param <X> The represented type.
- */
-public interface Embeddable<X> extends ManagedType<X> {}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/EmbeddableType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/EmbeddableType.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/EmbeddableType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,11 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type EmbeddableType represent embeddable types.
+ *
+ * @param <X> The represented type.
+ */
+public interface EmbeddableType<X> extends ManagedType<X> {
+}

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Entity.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Entity.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Entity.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,23 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- *  Instances of the type Entity represent entity types.
- *
- *  @param <X> The represented entity type.
- */
-public interface Entity<X> extends IdentifiableType<X> {
-
-    /**
-     *  Return the entity name
-     *  @return entity name
-     */
-    String getName();
-
-    /**
-     *  Return the Java type of the entity's id.
-     *  @return Java type of id
-     */
-    Class<?> getIdJavaType();
-}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/EntityType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/EntityType.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/EntityType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,19 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type EntityType represent entity types.
+ *
+ * @param <X> The represented entity type.
+ */
+public interface EntityType<X>
+		extends IdentifiableType<X>, Bindable<X> {
+
+	/**
+	 * Return the entity name
+	 *
+	 * @return entity name
+	 */
+	String getName();
+}
\ No newline at end of file

Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/IdentifiableType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,65 +1,113 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.metamodel;
 
 /**
- *  Instances of the type IdentifiableType represent entity or 
- *  mapped superclass types.
+ * Instances of the type IdentifiableType represent entity or
+ * mapped superclass types.
  *
- *  @param <X> The represented entity or mapped superclass type.
+ * @param <X> The represented entity or mapped superclass type.
  */
 public interface IdentifiableType<X> extends ManagedType<X> {
-	
-    /**
-     *  Return the attribute that corresponds to the id attribute of 
-     *  the entity or mapped superclass.
-     *  @param type  the type of the represented id attribute
-     *  @return id attribute
-     *  @throws IllegalArgumentException if id attribute of the given
-     *          name and type is not present in the identifiable type
-     */
-    <Y> Attribute<? super X, Y> getId(Class<Y> type);
 
-    /**
-     *  Return the attribute that corresponds to the version 
-     *	  attribute
-     *  of the entity or mapped superclass.
-     *  @param type  the type of the represented version attribute
-     *  @return version attribute
-     *  @throws IllegalArgumentException if version attribute of the 
-     * 				given name and type is not present in the 
-     *				identifiable type
-     */
-    <Y> Attribute<? super X, Y> getVersion(Class<Y> type);
+	/**
+	 * Return the attribute that corresponds to the id attribute of
+	 * the entity or mapped superclass.
+	 *
+	 * @param type the type of the represented id attribute
+	 *
+	 * @return id attribute
+	 *
+	 * @throws IllegalArgumentException if id attribute of the given
+	 *                                  type is not present in the identifiable type or if
+	 *                                  the identifiable type has an id class
+	 */
+	<Y> SingularAttribute<? super X, Y> getId(Class<Y> type);
 
-    /**
-     *  Return the attribute that corresponds to the id attribute 
-     *  declared by the entity or mapped superclass.
-     *  @param type  the type of the represented declared id 
-     * 					attribute
-     *  @return declared id attribute
-     *  @throws IllegalArgumentException if id attribute of the given
-     *          name and type is not present in the identifiable type
-     */
-    <Y> Attribute<X, Y> getDeclaredId(Class<Y> type);
+	/**
+	 * Return the attribute that corresponds to the version
+	 * attribute of the entity or mapped superclass.
+	 *
+	 * @param type the type of the represented version attribute
+	 *
+	 * @return version attribute
+	 *
+	 * @throws IllegalArgumentException if version attribute of the
+	 *                                  given type is not present in the identifiable type
+	 */
+	<Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);
 
-    /**
-     *  Return the attribute that corresponds to the version 
-     *  attribute declared by the entity or mapped superclass.
-     *  @param type  the type of the represented declared version 
-     *               attribute
-     *  @return declared version attribute
-     *  @throws IllegalArgumentException if version attribute of the 
-     * 				given name and type is not present in the 
-     *				identifiable type
-     */
-    <Y> Attribute<X, Y> getDeclaredVersion(Class<Y> type);
-	
-    /**
-     *  Return the identifiable type that corresponds to the most
-     *  specific mapped superclass or entity extended by the entity 
-     *  or mapped superclass.
-     *  @return supertype of identifiable type
-     */
-    IdentifiableType<? super X> getSupertype();
+	/**
+	 * Return the attribute that corresponds to the id attribute
+	 * declared by the entity or mapped superclass.
+	 *
+	 * @param type the type of the represented declared id attribute
+	 *
+	 * @return declared id attribute
+	 *
+	 * @throws IllegalArgumentException if id attribute of the given
+	 *                                  type is not declared in the identifiable type or if
+	 *                                  the identifiable type has an id class
+	 */
+	<Y> SingularAttribute<X, Y> getDeclaredId(Class<Y> type);
+
+	/**
+	 * Return the attribute that corresponds to the version
+	 * attribute declared by the entity or mapped superclass.
+	 *
+	 * @param type the type of the represented declared version
+	 * attribute
+	 *
+	 * @return declared version attribute
+	 *
+	 * @throws IllegalArgumentException if version attribute of the
+	 *                                  type is not declared in the identifiable type
+	 */
+	<Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> type);
+
+	/**
+	 * Return the identifiable type that corresponds to the most
+	 * specific mapped superclass or entity extended by the entity
+	 * or mapped superclass.
+	 *
+	 * @return supertype of identifiable type or null if no such supertype
+	 */
+	IdentifiableType<? super X> getSupertype();
+
+	/**
+	 * Whether or not the identifiable type has an id attribute.
+	 * Returns true for a simple id or embedded id; returns false
+	 * for an idclass.
+	 *
+	 * @return boolean indicating whether or not the identifiable
+	 *         type has a single id attribute
+	 */
+	boolean hasSingleIdAttribute();
+
+	/**
+	 * Whether or not the identifiable type has a version attribute.
+	 *
+	 * @return boolean indicating whether or not the identifiable
+	 *         type has a version attribute
+	 */
+	boolean hasVersionAttribute();
+
+	/**
+	 * Return the attributes corresponding to the id class of the
+	 * identifiable type.
+	 *
+	 * @return id attributes
+	 *
+	 * @throws IllegalArgumentException if the identifiable type
+	 *                                  does not have an id class
+	 */
+	java.util.Set<SingularAttribute<? super X, ?>> getIdClassAttributes();
+
+	/**
+	 * Return the type that represents the type of the id.
+	 *
+	 * @return type of id
+	 */
+	Type<?> getIdType();
 }
+

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/List.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/List.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/List.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,13 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * Instances of the type List represent persistent List-valued 
- * attributes.
- *
- * @param <X> The type the represented List belongs to
- * @param <E> The element type of the represented List
- */
-public interface List<X, E> 
-		extends AbstractCollection<X, java.util.List<E>, E> {}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/ListAttribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/ListAttribute.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/ListAttribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,14 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type ListAttribute represent persistent
+ * List-valued attributes.
+ *
+ * @param <X> The type the represented List belongs to
+ * @param <E> The element type of the represented List
+ */
+public interface ListAttribute<X, E>
+		extends PluralAttribute<X, java.util.List<E>, E> {
+}
\ No newline at end of file

Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/ManagedType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,186 +1,378 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.metamodel;
 
 /**
- *  Instances of the type ManagedType represent entity, mapped 
- *  superclass, and embeddable types.
+ * Instances of the type ManagedType represent entity, mapped
+ * superclass, and embeddable types.
  *
- *  @param <X> The represented type.
+ * @param <X> The represented type.
  */
-public interface ManagedType<X> extends Type<X>, Bindable<X> {
-    /**
-     *  Return the non-collection-valued attribute of the managed
-     *  type that corresponds to the specified name in the
-     *  represented type.
-     *  @param name  the name of the represented attribute
-     *  @return non-collection attribute with the given name
-     */
-    Attribute<? super X, ?> getAttribute(String name);
+public interface ManagedType<X> extends Type<X> {
 
-    /**
-     *  Return the non-collection-valued attribute of the managed 
-     *  type that corresponds to the specified name and Java type 
-     *  in therepresented type.
-     *  @param name  the name of the represented attribute
-     *  @param type  the type of the represented attribute
-     *  @return non-collection attribute with given name and type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <Y> Attribute<? super X, Y> getAttribute(String name, 
-                                             Class<Y> type);
+	/**
+	 * Return the attributes of the managed type.
+	 */
+	java.util.Set<Attribute<? super X, ?>> getAttributes();
 
-    /**
-     *  Return the declared non-collection-valued attribute of the 
-     *  managed type that corresponds to the specified name and Java 
-     *  in the represented type.
-     *  @param name  the name of the represented attribute
-     *  @param type  the type of the represented attribute
-     *  @return declared non-collection attribute of the given 
-     *          name and type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <Y> Attribute<X, Y> getDeclaredAttribute(String name, 
-                                             Class<Y> type);
-	
-    /**
-     *  Return the non-collection-valued attributes of the 
-     *  managed type.
-     *  @return non-collection attributes
-     */
-    java.util.Set<Attribute<? super X, ?>> getAttributes();
+	/**
+	 * Return the attributes declared by the managed type.
+	 */
+	java.util.Set<Attribute<X, ?>> getDeclaredAttributes();
 
-    /**
-     *  Return the non-collection-valued attributes declared by 
-     *  the managed type.
-     *  @return declared non-collection attributes
-     */
-    java.util.Set<Attribute<X, ?>> getDeclaredAttributes();
-	
-    /**
-     *  Return the Collection-valued attribute of the managed type 
-     *  that corresponds to the specified name and Java element type.
-     *  @param name  the name of the represented attribute
-     *  @param elementType  the element type of the represented 
-     *                      attribute
-     *  @return Collection attribute of the given name and element
-     *          type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */    
-    <E> Collection<? super X, E> getCollection(String name, 
-                                               Class<E> elementType);
+	/**
+	 * Return the single-valued attribute of the managed
+	 * type that corresponds to the specified name and Java type
+	 * in the represented type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param type the type of the represented attribute
+	 *
+	 * @return single-valued attribute with given name and type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not present in the managed type
+	 */
+	<Y> SingularAttribute<? super X, Y> getSingularAttribute(String name, Class<Y> type);
 
-    /**
-     *  Return the Set-valued attribute of the managed type that
-     *  corresponds to the specified name and Java element type.
-     *  @param name  the name of the represented attribute
-     *  @param elementType  the element type of the represented 
-     *                      attribute
-     *  @return Set attribute of the given name and element type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <E> Set<? super X, E> getSet(String name, Class<E> elementType);
+	/**
+	 * Return the declared single-valued attribute of the
+	 * managed type that corresponds to the specified name and Java
+	 * type in the represented type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param type the type of the represented attribute
+	 *
+	 * @return declared single-valued attribute of the given
+	 *         name and type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not declared in the managed type
+	 */
+	<Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(String name, Class<Y> type);
 
-    /**
-     *  Return the List-valued attribute of the managed type that
-     *  corresponds to the specified name and Java element type.
-     *  @param name  the name of the represented attribute
-     *  @param elementType  the element type of the represented 
-     *                      attribute
-     *  @return List attribute of the given name and element type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <E> List<? super X, E> getList(String name, Class<E> elementType);
+	/**
+	 * Return the single-valued attributes of the managed type.
+	 *
+	 * @return single-valued attributes
+	 */
+	java.util.Set<SingularAttribute<? super X, ?>> getSingularAttributes();
 
-    /**
-     *  Return the Map-valued attribute of the managed type that
-     *  corresponds to the specified name and Java key and value
-     *  types.
-     *  @param name  the name of the represented attribute
-     *  @param keyType  the key type of the represented attribute
-     *  @param valueType  the value type of the represented attribute
-     *  @return Map attribute of the given name and key and value
-     *  types
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <K, V> Map<? super X, K, V> getMap(String name, 
-                                       Class<K> keyType, 
-                                       Class<V> valueType);
+	/**
+	 * Return the single-valued attributes declared by the managed
+	 * type.
+	 *
+	 * @return declared single-valued attributes
+	 */
+	java.util.Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes();
 
-    /**
-     *  Return the Collection-valued attribute declared by the 
-     *  managed type that corresponds to the specified name and Java 
-     *  element type.
-     *  @param name  the name of the represented attribute
-     *  @param elementType  the element type of the represented 
-     *                      attribute
-     *  @return declared Collection attribute of the given name and 
-     *          element type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <E> Collection<X, E> getDeclaredCollection(String name, 
-                                               Class<E> elementType);
+	/**
+	 * Return the Collection-valued attribute of the managed type
+	 * that corresponds to the specified name and Java element type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param elementType the element type of the represented
+	 * attribute
+	 *
+	 * @return CollectionAttribute of the given name and element
+	 *         type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not present in the managed type
+	 */
+	<E> CollectionAttribute<? super X, E> getCollection(String name, Class<E> elementType);
 
-    /**
-     *  Return the Set-valued attribute declared by the managed type 
-     *  that corresponds to the specified name and Java element type.
-     *  @param name  the name of the represented attribute
-     *  @param elementType  the element type of the represented 
-     *                      attribute
-     *  @return declared Set attribute of the given name and 
-     *          element type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <E> Set<X, E> getDeclaredSet(String name, Class<E> elementType);
+	/**
+	 * Return the Set-valued attribute of the managed type that
+	 * corresponds to the specified name and Java element type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param elementType the element type of the represented
+	 * attribute
+	 *
+	 * @return SetAttribute of the given name and element type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not present in the managed type
+	 */
+	<E> SetAttribute<? super X, E> getSet(String name, Class<E> elementType);
 
-    /**
-     *  Return the List-valued attribute declared by the managed 
-     *  type that corresponds to the specified name and Java 
-     *  element type.
-     *  @param name  the name of the represented attribute
-     *  @param elementType  the element type of the represented 
-     *                      attribute
-     *  @return declared List attribute of the given name and 
-     *          element type
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <E> List<X, E> getDeclaredList(String name, Class<E> elementType);
+	/**
+	 * Return the List-valued attribute of the managed type that
+	 * corresponds to the specified name and Java element type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param elementType the element type of the represented
+	 * attribute
+	 *
+	 * @return ListAttribute of the given name and element type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not present in the managed type
+	 */
+	<E> ListAttribute<? super X, E> getList(String name, Class<E> elementType);
 
-    /**
-     *  Return the Map-valued attribute declared by the managed 
-     *  type that corresponds to the specified name and Java key 
-     *  and value types.
-     *  @param name  the name of the represented attribute
-     *  @param keyType  the key type of the represented attribute
-     *  @param valueType  the value type of the represented attribute
-     *  @return declared Map attribute of the given name and key 
-     *          and value types
-     *  @throws IllegalArgumentException if attribute of the given
-     *          name and type is not present in the managed type
-     */
-    <K, V> Map<X, K, V> getDeclaredMap(String name, 
-                                       Class<K> keyType, 
-                                       Class<V> valueType);
-    
-    /**
-     *  Return all collection-valued attributes of the managed type.
-     *  @return collection valued attributes
-     */
-    java.util.Set<AbstractCollection<? super X, ?, ?>> getCollections();
+	/**
+	 * Return the Map-valued attribute of the managed type that
+	 * corresponds to the specified name and Java key and value
+	 * types.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param keyType the key type of the represented attribute
+	 * @param valueType the value type of the represented attribute
+	 *
+	 * @return MapAttribute of the given name and key and value
+	 *         types
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not present in the managed type
+	 */
+	<K, V> MapAttribute<? super X, K, V> getMap(String name,
+												Class<K> keyType,
+												Class<V> valueType);
 
-    /**
-     *  Return all collection-valued attributes declared by the 
-     *  managedtype.
-     *  @return declared collection valued attributes
-     */
-    java.util.Set<AbstractCollection<X, ?, ?>> getDeclaredCollections();
+	/**
+	 * Return the Collection-valued attribute declared by the
+	 * managed type that corresponds to the specified name and Java
+	 * element type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param elementType the element type of the represented
+	 * attribute
+	 *
+	 * @return declared CollectionAttribute of the given name and
+	 *         element type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not declared in the managed type
+	 */
+	<E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType);
+
+	/**
+	 * Return the Set-valued attribute declared by the managed type
+	 * that corresponds to the specified name and Java element type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param elementType the element type of the represented
+	 * attribute
+	 *
+	 * @return declared SetAttribute of the given name and
+	 *         element type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not declared in the managed type
+	 */
+	<E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType);
+
+	/**
+	 * Return the List-valued attribute declared by the managed
+	 * type that corresponds to the specified name and Java
+	 * element type.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param elementType the element type of the represented
+	 * attribute
+	 *
+	 * @return declared ListAttribute of the given name and
+	 *         element type
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not declared in the managed type
+	 */
+	<E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
+
+	/**
+	 * Return the Map-valued attribute declared by the managed
+	 * type that corresponds to the specified name and Java key
+	 * and value types.
+	 *
+	 * @param name the name of the represented attribute
+	 * @param keyType the key type of the represented attribute
+	 * @param valueType the value type of the represented attribute
+	 *
+	 * @return declared MapAttribute of the given name and key
+	 *         and value types
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name and type is not declared in the managed type
+	 */
+	<K, V> MapAttribute<X, K, V> getDeclaredMap(String name,
+												Class<K> keyType,
+												Class<V> valueType);
+
+	/**
+	 * Return all collection-valued attributes of the managed type.
+	 *
+	 * @return collection valued attributes
+	 */
+	java.util.Set<PluralAttribute<? super X, ?, ?>> getCollections();
+
+	/**
+	 * Return all collection-valued attributes declared by the
+	 * managed type.
+	 *
+	 * @return declared collection valued attributes
+	 */
+	java.util.Set<PluralAttribute<X, ?, ?>> getDeclaredCollections();
+
+//String-based:
+
+	/**
+	 * Return the attribute of the managed
+	 * type that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return attribute with given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not present in the managed type
+	 */
+	Attribute<? super X, ?> getAttribute(String name);
+
+	/**
+	 * Return the declared attribute of the managed
+	 * type that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return attribute with given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not declared in the managed type
+	 */
+	Attribute<X, ?> getDeclaredAttribute(String name);
+
+	/**
+	 * Return the single-valued attribute of the managed type that
+	 * corresponds to the specified name in the represented type.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return single-valued attribute with the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not present in the managed type
+	 */
+	SingularAttribute<? super X, ?> getSingularAttribute(String name);
+
+	/**
+	 * Return the declared single-valued attribute of the managed
+	 * type that corresponds to the specified name in the
+	 * represented type.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return declared single-valued attribute of the given
+	 *         name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not declared in the managed type
+	 */
+	SingularAttribute<X, ?> getDeclaredSingularAttribute(String name);
+
+	/**
+	 * Return the Collection-valued attribute of the managed type
+	 * that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return CollectionAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not present in the managed type
+	 */
+	CollectionAttribute<? super X, ?> getCollection(String name);
+
+	/**
+	 * Return the Set-valued attribute of the managed type that
+	 * corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return SetAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not present in the managed type
+	 */
+	SetAttribute<? super X, ?> getSet(String name);
+
+	/**
+	 * Return the List-valued attribute of the managed type that
+	 * corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return ListAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not present in the managed type
+	 */
+	ListAttribute<? super X, ?> getList(String name);
+
+	/**
+	 * Return the Map-valued attribute of the managed type that
+	 * corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return MapAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not present in the managed type
+	 */
+	MapAttribute<? super X, ?, ?> getMap(String name);
+
+	/**
+	 * Return the Collection-valued attribute declared by the
+	 * managed type that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return declared CollectionAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not declared in the managed type
+	 */
+	CollectionAttribute<X, ?> getDeclaredCollection(String name);
+
+	/**
+	 * Return the Set-valued attribute declared by the managed type
+	 * that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return declared SetAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not declared in the managed type
+	 */
+	SetAttribute<X, ?> getDeclaredSet(String name);
+
+	/**
+	 * Return the List-valued attribute declared by the managed
+	 * type that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return declared ListAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not declared in the managed type
+	 */
+	ListAttribute<X, ?> getDeclaredList(String name);
+
+	/**
+	 * Return the Map-valued attribute declared by the managed
+	 * type that corresponds to the specified name.
+	 *
+	 * @param name the name of the represented attribute
+	 *
+	 * @return declared MapAttribute of the given name
+	 *
+	 * @throws IllegalArgumentException if attribute of the given
+	 *                                  name is not declared in the managed type
+	 */
+	MapAttribute<X, ?, ?> getDeclaredMap(String name);
 }
+

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Map.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Map.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Map.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,26 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * Instances of the type Map represent persistent Map-valued
- * attributes.
- *
- * @param <X> The type the represented Map belongs to
- * @param <K> The type of the key of the represented Map
- * @param <V> The type of the value of the represented Map
- */
-public interface Map<X, K, V> 
-		extends AbstractCollection<X, java.util.Map<K, V>, V> {
-    /**
-     * Return the Java type of the map key.
-     * @return Java key type
-     */
-    Class<K> getKeyJavaType();
-
-    /**
-     * Return the type representing the key type of the map.
-     * @return type representing key type
-     */
-    Type<K> getKeyType();
-}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/MapAttribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/MapAttribute.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/MapAttribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,29 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type MapAttribute represent persistent Map-valued
+ * attributes.
+ *
+ * @param <X> The type the represented Map belongs to
+ * @param <K> The type of the key of the represented Map
+ * @param <V> The type of the value of the represented Map
+ */
+public interface MapAttribute<X, K, V>
+		extends PluralAttribute<X, java.util.Map<K, V>, V> {
+
+	/**
+	 * Return the Java type of the map key.
+	 *
+	 * @return Java key type
+	 */
+	Class<K> getKeyJavaType();
+
+	/**
+	 * Return the type representing the key type of the map.
+	 *
+	 * @return type representing key type
+	 */
+	Type<K> getKeyType();
+}

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclass.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclass.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclass.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,11 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- *  Instances of the type MappedSuperclass represent mapped
- *  superclass types.
- *
- *  @param <X> The represented entity type
- */
-public interface MappedSuperclass<X> extends IdentifiableType<X> {}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclassType.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclassType.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/MappedSuperclassType.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,13 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type MappedSuperclassType represent mapped
+ * superclass types.
+ *
+ * @param <X> The represented entity type
+ */
+public interface MappedSuperclassType<X> extends IdentifiableType<X> {
+}
+

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Member.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Member.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Member.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,48 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * A member of a Java type
- *
- * @param <X> The represented type that contains the member
- * @param <Y> The type of the represented member
- */
-public interface Member<X, Y> {
-    //String getName(); //TODO: do we need this? 
-					// the java.lang.reflect.Member has it
-
-    /**
-     *  Return the managed type representing the type in which 
-     *  the member was declared.
-     *  @return declaring type
-     */
-    ManagedType<X> getDeclaringType();
-
-    /**
-     *  Return the Java type of the represented member.
-     *  @return Java type
-     */
-    Class<Y> getMemberJavaType();
-
-    /**
-     *  Return the java.lang.reflect.Member for the represented 
-     *  member.
-     *  @return corresponding java.lang.reflect.Member
-     */
-    java.lang.reflect.Member getJavaMember();
-
-    /**
-     *  Is the member an association
-     *  @return whether an association
-     */
-    boolean isAssociation();
-
-    /**
-     *  Is the member collection-valued
-     *  @return whether a collection
-     */
-    boolean isCollection();
-	
-    //TODO: fetch type
-}

Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Metamodel.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Metamodel.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Metamodel.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,55 +1,67 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.metamodel;
 
 /**
  * Provides access to the metamodel of persistent
- * entities in the persistence unit. 
- *
+ * entities in the persistence unit.
  */
 public interface Metamodel {
 
-    /**
-     *  Return the metamodel entity representing the entity type.
-     *  @param clazz  the type of the represented entity
-     *  @return the metamodel entity
-     *  @throws IllegalArgumentException if not an entity
-     */
-    <X> Entity<X> entity(Class<X> clazz);
+	/**
+	 * Return the metamodel entity type representing the entity.
+	 *
+	 * @param cls the type of the represented entity
+	 *
+	 * @return the metamodel entity type
+	 *
+	 * @throws IllegalArgumentException if not an entity
+	 */
+	<X> EntityType<X> entity(Class<X> cls);
 
-    /**
-     *  Return the metamodel managed type representing the 
-     *  entity, mapped superclass, or embeddable type.
-     *  @param clazz  the type of the represented managed class
-     *  @return the metamodel managed type
-     *  @throws IllegalArgumentException if not a managed class
-     */
-    <X> ManagedType<X> type(Class<X> clazz);
+	/**
+	 * Return the metamodel managed type representing the
+	 * entity, mapped superclass, or embeddable class.
+	 *
+	 * @param cls the type of the represented managed class
+	 *
+	 * @return the metamodel managed type
+	 *
+	 * @throws IllegalArgumentException if not a managed class
+	 */
+	<X> ManagedType<X> type(Class<X> cls);
 
-    /**
-     *  Return the metamodel embeddable type representing the
-     *  embeddable type.
-     *  @param clazz  the type of the represented embeddable class
-     *  @return the metamodel embeddable type
-     *  @throws IllegalArgumentException if not an embeddable class
-     */
-    <X> Embeddable<X> embeddable(Class<X> clazz);
+	/**
+	 * Return the metamodel embeddable type representing the
+	 * embeddable class.
+	 *
+	 * @param cls the type of the represented embeddable class
+	 *
+	 * @return the metamodel embeddable type
+	 *
+	 * @throws IllegalArgumentException if not an embeddable class
+	 */
+	<X> EmbeddableType<X> embeddable(Class<X> cls);
 
-    /**
-     *  Return the metamodel managed types.
-     *  @return the metamodel managed types
-     */
-    java.util.Set<ManagedType<?>> getManagedTypes();
+	/**
+	 * Return the metamodel managed types.
+	 *
+	 * @return the metamodel managed types
+	 */
+	java.util.Set<ManagedType<?>> getManagedTypes();
 
-    /**
-     * Return the metamodel entity types.
-     * @return the metamodel entity types
-     */
-    java.util.Set<Entity<?>> getEntities();
+	/**
+	 * Return the metamodel entity types.
+	 *
+	 * @return the metamodel entity types
+	 */
+	java.util.Set<EntityType<?>> getEntities();
 
-    /**
-     * Return the metamodel embeddable types.
-     * @return the metamodel embeddable types
-     */
-    java.util.Set<Embeddable<?>> getEmbeddables();
+	/**
+	 * Return the metamodel embeddable types.
+	 *
+	 * @return the metamodel embeddable types
+	 */
+	java.util.Set<EmbeddableType<?>> getEmbeddables();
 }
+

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/PluralAttribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/PluralAttribute.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/PluralAttribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,34 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type PluralAttribute represent
+ * persistent collection-valued attributes.
+ *
+ * @param <X> The type the represented collection belongs to
+ * @param <C> The type of the represented collection
+ * @param <E> The element type of the represented collection
+ */
+public interface PluralAttribute<X, C, E>
+		extends Attribute<X, C>, Bindable<E> {
+
+	public static enum CollectionType {
+		COLLECTION, SET, LIST, MAP
+	}
+
+	/**
+	 * Return the collection type.
+	 *
+	 * @return collection type
+	 */
+	CollectionType getCollectionType();
+
+	/**
+	 * Return the type representing the element type of the
+	 * collection.
+	 *
+	 * @return element type
+	 */
+	Type<E> getElementType();
+}

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Set.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Set.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Set.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,14 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-/**
- * Instances of the type Set represent persistent Set-valued
- * attributes.
- *
- * @param <X> The type the represented Set belongs to
- * @param <E> The element type of the represented Set
- */
-public interface Set<X, E> 
-		extends AbstractCollection<X, java.util.Set<E>, E> {}
-

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/SetAttribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/SetAttribute.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/SetAttribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,15 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type SetAttribute represent persistent Set-valued
+ * attributes.
+ *
+ * @param <X> The type the represented Set belongs to
+ * @param <E> The element type of the represented Set
+ */
+public interface SetAttribute<X, E>
+		extends PluralAttribute<X, java.util.Set<E>, E> {
+}
+

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/SingularAttribute.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/SingularAttribute.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/SingularAttribute.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,44 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+/**
+ * Instances of the type SingularAttribute represents persistent
+ * single-valued properties or fields.
+ *
+ * @param <X> The type containing the represented attribute
+ * @param <T> The type of the represented attribute
+ */
+public interface SingularAttribute<X, T>
+		extends Attribute<X, T>, Bindable<T> {
+
+	/**
+	 * Is the attribute an id attribute.
+	 *
+	 * @return boolean indicating whether or not attribute is an id
+	 */
+	boolean isId();
+
+	/**
+	 * Is the attribute a version attribute.
+	 *
+	 * @return boolean indicating whether or not attribute is
+	 *         a version attribute
+	 */
+	boolean isVersion();
+
+	/**
+	 * Can the attribute be null.
+	 *
+	 * @return boolean indicating whether or not the attribute can
+	 *         be null
+	 */
+	boolean isOptional();
+
+	/**
+	 * Return the type that represents the type of the attribute.
+	 *
+	 * @return type of attribute
+	 */
+	Type<T> getType();
+}

Added: jpa-api/trunk/src/main/java/javax/persistence/metamodel/StaticMetamodel.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/StaticMetamodel.java	                        (rev 0)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/StaticMetamodel.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -0,0 +1,20 @@
+// $Id:$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+package javax.persistence.metamodel;
+
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * The StaticMetamodel annotation specifies that the class
+ * is a metamodel class that represents the entity, mapped
+ * superclass, or embeddable class designated by the value
+ * element.
+ */
+ at Target(ElementType.TYPE)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface StaticMetamodel {
+	Class<?> value();
+}

Modified: jpa-api/trunk/src/main/java/javax/persistence/metamodel/Type.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/Type.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/Type.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,28 +1,30 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
+// $Id$
+// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
 package javax.persistence.metamodel;
 
 /**
- * Instances of the type Type represent persistent object 
+ * Instances of the type Type represent persistent object
  * or attribute types.
  *
  * @param <X>  The type of the represented object or attribute
  */
 public interface Type<X> {
-	
+
 	public static enum PersistenceType {
 		ENTITY, EMBEDDABLE, MAPPED_SUPERCLASS, BASIC
 	}
-	
-    /**
-     *  Return the persistence type
-     *  @return persistence type
-     */	
-    PersistenceType getPersistenceType();
-	
-    /**
-     *  Return the represented Java type
-     *  @return Java type
-     */
-    Class<X> getJavaType();
+
+	/**
+	 * Return the persistence type.
+	 *
+	 * @return persistence type
+	 */
+	PersistenceType getPersistenceType();
+
+	/**
+	 * Return the represented Java type.
+	 *
+	 * @return Java type
+	 */
+	Class<X> getJavaType();
 }

Deleted: jpa-api/trunk/src/main/java/javax/persistence/metamodel/TypesafeMetamodel.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/metamodel/TypesafeMetamodel.java	2009-07-08 10:42:49 UTC (rev 17037)
+++ jpa-api/trunk/src/main/java/javax/persistence/metamodel/TypesafeMetamodel.java	2009-07-08 10:58:24 UTC (rev 17038)
@@ -1,20 +0,0 @@
-// $Id$
-// EJB3 Specification Copyright 2004-2009 Sun Microsystems, Inc.
-package javax.persistence.metamodel;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The TypesafeMetamodel annotation specifies that the class
- * is a metamodel class that represents the entity, mapped 
- * superclass, or embeddable class designated by the value
- * element.
- */
- at Target(ElementType.TYPE)
- at Retention(RetentionPolicy.RUNTIME)
-public @interface TypesafeMetamodel {
-    Class<?> value();
-}




More information about the hibernate-commits mailing list