diff --git a/src/main/java/com/avaje/ebean/Model.java b/src/main/java/com/avaje/ebean/Model.java index d9594fac2..d57311474 100644 --- a/src/main/java/com/avaje/ebean/Model.java +++ b/src/main/java/com/avaje/ebean/Model.java @@ -1,5 +1,7 @@ package com.avaje.ebean; +import com.avaje.ebean.text.PathProperties; + import java.util.List; import java.util.Map; import java.util.Set; @@ -176,11 +178,11 @@ public abstract class Model { * Typically a Finder is defined as a public static field on an entity bean class to provide a * nice way to write queries. * - * @param I + * @param * The Id type. This is most often a {@link Long} but is also often a {@link UUID} or * {@link String}. - * - * @param T + * + * @param * The bean type */ public static class Finder { @@ -265,7 +267,7 @@ public abstract class Model { * Retrieves an entity by ID. * *

- * Equivilent to {@link EbeanServer#find(Class, Object)} + * Equivalent to {@link EbeanServer#find(Class, Object)} */ public T byId(I id) { return db().find(type, id); @@ -275,7 +277,7 @@ public abstract class Model { * Creates an entity reference for this ID. * *

- * Equivilent to {@link EbeanServer#getReference(Class, Object)} + * Equivalent to {@link EbeanServer#getReference(Class, Object)} */ public T ref(I id) { return db().getReference(type, id); @@ -285,7 +287,7 @@ public abstract class Model { * Creates a filter for sorting and filtering lists of entities locally without going back to * the database. *

- * Equivilent to {@link EbeanServer#filter(Class)} + * Equivalent to {@link EbeanServer#filter(Class)} */ public Filter filter() { return db().filter(type); @@ -294,12 +296,19 @@ public abstract class Model { /** * Creates a query. *

- * Equivilent to {@link EbeanServer#find(Class)} + * Equivalent to {@link EbeanServer#find(Class)} */ public Query query() { return db().find(type); } + /** + * Creates a query applying the path properties to set the select and fetch clauses. + */ + public Query apply(PathProperties pathProperties) { + return db().find(type).apply(pathProperties); + } + /** * Returns the next identity value. * @@ -313,7 +322,7 @@ public abstract class Model { /** * Executes a query and returns the results as a list of IDs. *

- * Equivilent to {@link Query#findIds()} + * Equivalent to {@link Query#findIds()} */ public List findIds() { return query().findIds(); @@ -324,7 +333,7 @@ public abstract class Model { *

* The same as {@link #all()} *

- * Equivilent to {@link Query#findList()} + * Equivalent to {@link Query#findList()} */ public List findList() { return query().findList(); @@ -333,7 +342,7 @@ public abstract class Model { /** * Returns all the entities of the given type as a set. *

- * Equivilent to {@link Query#findSet()} + * Equivalent to {@link Query#findSet()} */ public Set findSet() { return query().findSet(); @@ -342,7 +351,7 @@ public abstract class Model { /** * Retrieves all entities of the given type as a map of objects. *

- * Equivilent to {@link Query#findMap()} + * Equivalent to {@link Query#findMap()} */ public Map findMap() { return query().findMap(); @@ -352,7 +361,7 @@ public abstract class Model { * Executes the query and returns the results as a map of the objects specifying the map key * property. *

- * Equivilent to {@link Query#findMap(String, Class)} + * Equivalent to {@link Query#findMap(String, Class)} */ public Map findMap(String keyProperty, Class keyType) { return query().findMap(keyProperty, keyType); @@ -362,7 +371,7 @@ public abstract class Model { * Return a PagedList of all entities of the given type (use where() to specify predicates as * needed). *

- * Equivilent to {@link Query#findPagedList(int, int)} + * Equivalent to {@link Query#findPagedList(int, int)} */ public PagedList findPagedList(int pageIndex, int pageSize) { return query().findPagedList(pageIndex, pageSize); @@ -371,7 +380,7 @@ public abstract class Model { /** * Executes a find row count query in a background thread. *

- * Equivilent to {@link Query#findFutureRowCount()} + * Equivalent to {@link Query#findFutureRowCount()} */ public FutureRowCount findFutureRowCount() { return query().findFutureRowCount(); @@ -380,7 +389,7 @@ public abstract class Model { /** * Returns the total number of entities for this type. * *

- * Equivilent to {@link Query#findRowCount()} + * Equivalent to {@link Query#findRowCount()} */ public int findRowCount() { return query().findRowCount(); @@ -397,7 +406,7 @@ public abstract class Model { * Explicitly sets a comma delimited list of the properties to fetch on the 'main' entity bean, * to load a partial object. *

- * Equivilent to {@link Query#select(String)} + * Equivalent to {@link Query#select(String)} */ public Query select(String fetchProperties) { return query().select(fetchProperties); @@ -406,7 +415,7 @@ public abstract class Model { /** * Specifies a path to load including all its properties. *

- * Equivilent to {@link Query#fetch(String)} + * Equivalent to {@link Query#fetch(String)} */ public Query fetch(String path) { return query().fetch(path); @@ -416,7 +425,7 @@ public abstract class Model { * Additionally specifies a FetchConfig to specify a 'query join' and/or define the * lazy loading query. *

- * Equivilent to {@link Query#fetch(String, FetchConfig)} + * Equivalent to {@link Query#fetch(String, FetchConfig)} */ public Query fetch(String path, FetchConfig joinConfig) { return query().fetch(path, joinConfig); @@ -426,7 +435,7 @@ public abstract class Model { * Specifies a path to fetch with a specific list properties to include, to load a partial * object. *

- * Equivilent to {@link Query#fetch(String, String)} + * Equivalent to {@link Query#fetch(String, String)} */ public Query fetch(String path, String fetchProperties) { return query().fetch(path, fetchProperties); @@ -436,7 +445,7 @@ public abstract class Model { * Additionally specifies a FetchConfig to use a separate query or lazy loading to * load this path. *

- * Equivilent to {@link Query#fetch(String, String, FetchConfig)} + * Equivalent to {@link Query#fetch(String, String, FetchConfig)} */ public Query fetch(String assocProperty, String fetchProperties, FetchConfig fetchConfig) { return query().fetch(assocProperty, fetchProperties, fetchConfig); @@ -446,7 +455,7 @@ public abstract class Model { * Adds expressions to the where clause with the ability to chain on the * ExpressionList. *

- * Equivilent to {@link Query#where()} + * Equivalent to {@link Query#where()} */ public ExpressionList where() { return query().where(); @@ -458,7 +467,7 @@ public abstract class Model { *

* This is exactly the same as {@link #orderBy}. *

- * Equivilent to {@link Query#order()} + * Equivalent to {@link Query#order()} */ public OrderBy order() { return query().order(); @@ -480,7 +489,7 @@ public abstract class Model { *

* This is exactly the same as {@link #order}. *

- * Equivilent to {@link Query#orderBy()} + * Equivalent to {@link Query#orderBy()} */ public OrderBy orderBy() { return query().orderBy(); @@ -499,7 +508,7 @@ public abstract class Model { /** * Sets the first row to return for this query. *

- * Equivilent to {@link Query#setFirstRow(int)} + * Equivalent to {@link Query#setFirstRow(int)} */ public Query setFirstRow(int firstRow) { return query().setFirstRow(firstRow); @@ -508,7 +517,7 @@ public abstract class Model { /** * Sets the maximum number of rows to return in the query. *

- * Equivilent to {@link Query#setMaxRows(int)} + * Equivalent to {@link Query#setMaxRows(int)} */ public Query setMaxRows(int maxRows) { return query().setMaxRows(maxRows); @@ -521,7 +530,7 @@ public abstract class Model { * Use this to perform a find byId query but with additional control over the query such as * using select and fetch to control what parts of the object graph are returned. *

- * Equivilent to {@link Query#setId(Object)} + * Equivalent to {@link Query#setId(Object)} */ public Query setId(Object id) { return query().setId(id); @@ -530,7 +539,7 @@ public abstract class Model { /** * Create and return a new query using the OQL. *

- * Equivilent to {@link EbeanServer#createQuery(Class, String)} + * Equivalent to {@link EbeanServer#createQuery(Class, String)} */ public Query setQuery(String oql) { return db().createQuery(type, oql); @@ -539,7 +548,7 @@ public abstract class Model { /** * Create and return a new query based on the RawSql. *

- * Equivilent to {@link Query#setRawSql(RawSql)} + * Equivalent to {@link Query#setRawSql(RawSql)} */ public Query setRawSql(RawSql rawSql) { return query().setRawSql(rawSql);