- Type Parameters:
SELF
- The builder typeT
- The entity bean type
- All Known Subinterfaces:
Query<T>
,QueryBuilder<SELF,
,T> SpiFetchGroupQuery<T>
-
Method Summary
Modifier and TypeMethodDescriptionApply the path properties replacing the select and fetch clauses.distinctOn
(String distinctOn) Set DISTINCT ON clause.Specify a path to fetch eagerly including all its properties.fetch
(String path, FetchConfig fetchConfig) Additionally specify a JoinConfig to specify a "query join" and or define the lazy loading query.Specify a path to fetch eagerly including specific properties.fetch
(String path, String fetchProperties, FetchConfig fetchConfig) Additionally specify a FetchConfig to use a separate query or lazy loading to load this path.fetchCache
(String path) Fetch the path eagerly using L2 cache.fetchCache
(String path, String fetchProperties) Fetch the path and properties using L2 bean cache.Fetch the path lazily (via batch lazy loading).Fetch the path and properties lazily (via batch lazy loading).fetchQuery
(String path) Fetch the path eagerly using a "query join" (separate SQL query).fetchQuery
(String path, String fetchProperties) Fetch the path and properties using a "query join" (separate SQL query).select
(FetchGroup<T> fetchGroup) Apply the fetchGroup which defines what part of the object graph to load.Specify the properties to fetch on the root level entity bean in comma delimited format.
-
Method Details
-
apply
Apply the path properties replacing the select and fetch clauses.This is typically used when the FetchPath is applied to both the query and the JSON output.
-
select
Specify the properties to fetch on the root level entity bean in comma delimited format.The Id property is automatically included in the properties to fetch unless setDistinct(true) is set on the query.
Use
fetch(String, String)
to specify specific properties to fetch on other non-root level paths of the object graph.List<Customer> customers = DB.find(Customer.class) // Only fetch the customer id, name and status. // This is described as a "Partial Object" .select("name, status") .where.ilike("name", "rob%") .findList();
- Parameters:
fetchProperties
- the properties to fetch for this bean (* = all properties).
-
distinctOn
Set DISTINCT ON clause. This is a Postgres only SQL feature.- Parameters:
distinctOn
- The properties to include in the DISTINCT ON clause.
-
select
Apply the fetchGroup which defines what part of the object graph to load. -
fetch
Specify a path to fetch eagerly including specific properties.Ebean will endeavour to fetch this path using a SQL join. If Ebean determines that it can not use a SQL join (due to maxRows or because it would result in a cartesian product) Ebean will automatically convert this fetch query into a "query join" - i.e. use fetchQuery().
// query orders... List<Order> orders = DB.find(Order.class) // fetch the customer... // ... getting the customers name and phone number .fetch("customer", "name, phoneNumber") // ... also fetch the customers billing address (* = all properties) .fetch("customer.billingAddress", "*") .findList();
If columns is null or "*" then all columns/properties for that path are fetched.
// fetch customers (their id, name and status) List<Customer> customers = DB.find(Customer.class) .select("name, status") .fetch("contacts", "firstName,lastName,email") .findList();
- Parameters:
path
- the property path we wish to fetch eagerly.fetchProperties
- properties of the associated bean that you want to include in the fetch (* means all properties, null also means all properties).
-
fetchQuery
Fetch the path and properties using a "query join" (separate SQL query).This is the same as:
fetch(path, fetchProperties, FetchConfig.ofQuery())
This would be used instead of a fetch() when we use a separate SQL query to fetch this part of the object graph rather than a SQL join.
We might typically get a performance benefit when the path to fetch is a OneToMany or ManyToMany, the 'width' of the 'root bean' is wide and the cardinality of the many is high.
- Parameters:
path
- the property path we wish to fetch eagerly.fetchProperties
- properties of the associated bean that you want to include in the fetch (* means all properties, null also means all properties).
-
fetchCache
Fetch the path and properties using L2 bean cache.- Parameters:
path
- The path of the beans we are fetching from L2 cache.fetchProperties
- The properties that should be loaded.
-
fetchLazy
Fetch the path and properties lazily (via batch lazy loading).This is the same as:
fetch(path, fetchProperties, FetchConfig.ofLazy())
The reason for using fetchLazy() is to either:
- Control/tune what is fetched as part of lazy loading
- Make use of the L2 cache, build this part of the graph from L2 cache
- Parameters:
path
- the property path we wish to fetch lazily.fetchProperties
- properties of the associated bean that you want to include in the fetch (* means all properties, null also means all properties).
-
fetch
Additionally specify a FetchConfig to use a separate query or lazy loading to load this path.// fetch customers (their id, name and status) List<Customer> customers = DB.find(Customer.class) .select("name, status") .fetch("contacts", "firstName,lastName,email", FetchConfig.ofLazy(10)) .findList();
- Parameters:
path
- the property path we wish to fetch eagerly.
-
fetch
Specify a path to fetch eagerly including all its properties.Ebean will endeavour to fetch this path using a SQL join. If Ebean determines that it can not use a SQL join (due to maxRows or because it would result in a cartesian product) Ebean will automatically convert this fetch query into a "query join" - i.e. use fetchQuery().
// fetch customers (their id, name and status) List<Customer> customers = DB.find(Customer.class) // eager fetch the contacts .fetch("contacts") .findList();
- Parameters:
path
- the property path we wish to fetch eagerly.
-
fetchQuery
Fetch the path eagerly using a "query join" (separate SQL query).This is the same as:
fetch(path, FetchConfig.ofQuery())
This would be used instead of a fetch() when we use a separate SQL query to fetch this part of the object graph rather than a SQL join.
We might typically get a performance benefit when the path to fetch is a OneToMany or ManyToMany, the 'width' of the 'root bean' is wide and the cardinality of the many is high.
- Parameters:
path
- the property path we wish to fetch eagerly
-
fetchCache
Fetch the path eagerly using L2 cache. -
fetchLazy
Fetch the path lazily (via batch lazy loading).This is the same as:
fetch(path, FetchConfig.ofLazy())
The reason for using fetchLazy() is to either:
- Control/tune what is fetched as part of lazy loading
- Make use of the L2 cache, build this part of the graph from L2 cache
- Parameters:
path
- the property path we wish to fetch lazily.
-
fetch
Additionally specify a JoinConfig to specify a "query join" and or define the lazy loading query.// fetch customers (their id, name and status) List<Customer> customers = DB.find(Customer.class) // lazy fetch contacts with a batch size of 100 .fetch("contacts", FetchConfig.ofLazy(100)) .findList();
-