|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IQuery
Provides methods for directly querying object graphs. As far as is possible,
IQuery should be considered the lowest level DB-access (SELECT) interface.
Unlike the IUpdate
interface, using other methods will most
likely not leave the database in an inconsitent state, but may provide stale
data in some situations.
By convention, all methods that begin with get
will never
return a null or empty Collection
, but instead will throw
a ValidationException
.
Method Summary | ||
---|---|---|
|
find(Class<T> klass,
long id)
lookup an entity by class and id. |
|
|
findAll(Class<T> klass,
ome.parameters.Filter filter)
lookup all entities that belong to this class and match filter. |
|
|
findAllByExample(T example,
ome.parameters.Filter filter)
search based on provided example entity. |
|
|
findAllByFullText(Class<T> type,
String query,
ome.parameters.Parameters parameters)
executes a full text search based on Lucene. |
|
|
findAllByQuery(String queryName,
ome.parameters.Parameters parameters)
executes the stored query with the given name. |
|
|
findAllByString(Class<T> klass,
String field,
String stringValue,
boolean caseSensitive,
ome.parameters.Filter filter)
search a given field matching against a String. |
|
|
findByExample(T example)
search based on provided example entity. |
|
|
findByQuery(String queryName,
ome.parameters.Parameters parameters)
executes the stored query with the given name. |
|
|
findByString(Class<T> klass,
String field,
String value)
search a given field matching against a String. |
|
|
get(Class<T> klass,
long id)
lookup an entity by class and id. |
|
List<Object[]> |
projection(String query,
ome.parameters.Parameters parameters)
Return a list of Java Object instances (not IObject
instances). |
|
|
refresh(T iObject)
refreshes an entire IObject graph, recursive loading all data for
the managed instances in the graph from the database. |
Method Detail |
---|
<T extends ome.model.IObject> T get(Class<T> klass, long id) throws ome.conditions.ValidationException
klass
- the type of the entity. Not null.id
- the entity's id
ome.conditions.ValidationException
- if the id doesn't exist.<T extends ome.model.IObject> T find(Class<T> klass, long id)
klass
- klass the type of the entity. Not null.id
- the entity's id
<T extends ome.model.IObject> List<T> findAll(Class<T> klass, ome.parameters.Filter filter)
klass
- entity type to be searched. Not null.filter
- filters the result set. Can be null.
<T extends ome.model.IObject> T findByExample(T example) throws ome.conditions.ApiUsageException
id
field. For
that, use find(Class, long)
, get(Class, long)
,
findByQuery(String, Parameters)
, or
findAllByQuery(String, Parameters)
example
- Non-null example object.
ome.conditions.ApiUsageException
- if more than one result is return.<T extends ome.model.IObject> List<T> findAllByExample(T example, ome.parameters.Filter filter)
Filter
object.
Note: findAllbyExample does not operate on the id
field.
For that, use find(Class, long)
, get(Class, long)
,
findByQuery(String, Parameters)
, or
findAllByQuery(String, Parameters)
example
- Non-null example object.filter
- filters the result set. Can be null.
<T extends ome.model.IObject> T findByString(Class<T> klass, String field, String value) throws ome.conditions.ApiUsageException
klass
- type of entity to be searchedfield
- the name of the field, either as simple string or as public
final static from the entity class, e.g.
Project.NAME
value
- String used for search.
ome.conditions.ApiUsageException
- if more than one result.<T extends ome.model.IObject> List<T> findAllByString(Class<T> klass, String field, String stringValue, boolean caseSensitive, ome.parameters.Filter filter)
Filter
instance.
klass
- type of entity to be searched. Not null.field
- the name of the field, either as simple string or as public
final static from the entity class, e.g.
Project.NAME
. Not null.value
- String used for search. Not null.caseSensitive
- whether to use LIKE or ILIKEfilter
- filters the result set. Can be null.
<T extends ome.model.IObject> T findByQuery(String queryName, ome.parameters.Parameters parameters) throws ome.conditions.ValidationException
queryName
- String identifier of the query to executeparameters
- array of QueryParameter
. Not null. The
QueryParameter.name
field maps to a field-name which
is then matched against the QueryParameter.value
ome.conditions.ValidationException
<T extends ome.model.IObject> List<T> findAllByQuery(String queryName, ome.parameters.Parameters parameters)
IObject
instances. This means
all must be of the form:
select this from SomeModelClass this ...though the alias "this" is unimportant. Do not try to return multiple classes in one call like:
select this, that from SomeClass this, SomeOtherClass that ...nor to project values out of an object:
select this.name from SomeClass this ...If a
Page
is desired, add it to the query parameters.
queryName
- String identifier of the query to execute. Not null.parameters
- array of QueryParameter
. The
QueryParameter.name
field maps to a field-name which
is then matched against the QueryParameter.value
<T extends ome.model.IObject> List<T> findAllByFullText(Class<T> type, String query, ome.parameters.Parameters parameters)
T
- type
- A non-null class specification of which type should be
searched.query
- A non-null query string. An empty string will return no
results.parameters
- Currently the parameters themselves are unusued. But the
Parameters#getFilter()
can be used to limit the number
of results returned (Filter#maxResults()
) or the
user for who the results will be found (Filter.owner()
).
IObject
instances. Never null.List<Object[]> projection(String query, ome.parameters.Parameters parameters)
Object
instances (not IObject
instances). These are the column names as specified in the HQL
select statement (more than one is required).
If an aggregation statement is used, a group by clause must be added.
Examples:
<T extends ome.model.IObject> T refresh(T iObject) throws ome.conditions.ApiUsageException
IObject
graph, recursive loading all data for
the managed instances in the graph from the database. If any non-managed
entities are detected (e.g. without ids), an ApiUsageException
will be thrown.
iObject
- Non-null managed IObject
graph which should have all
values re-assigned from the database
IObject
graph (with possible additions and
deletions) which is in-sync with the database.
ome.conditions.ApiUsageException
- if any non-managed entities are found.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Version: Beta-4.2.0-r7571-b29
Copyright © 2009 The University of Dundee. All Rights Reserved.