public interface IQuery extends ServiceInterface
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
.Filter
,
Parameters
,
QueryParameter
Modifier and Type | Method and Description |
---|---|
<T extends IObject> |
find(Class<T> klass,
long id)
lookup an entity by class and id.
|
<T extends IObject> |
findAll(Class<T> klass,
Filter filter)
lookup all entities that belong to this class and match filter.
|
<T extends IObject> |
findAllByExample(T example,
Filter filter)
search based on provided example entity.
|
<T extends IObject> |
findAllByFullText(Class<T> type,
String query,
Parameters parameters)
executes a full text search based on Lucene.
|
<T extends IObject> |
findAllByQuery(String queryName,
Parameters parameters)
executes the stored query with the given name.
|
<T extends IObject> |
findAllByString(Class<T> klass,
String field,
String stringValue,
boolean caseSensitive,
Filter filter)
search a given field matching against a String.
|
<T extends IObject> |
findByExample(T example)
search based on provided example entity.
|
<T extends IObject> |
findByQuery(String queryName,
Parameters parameters)
executes the stored query with the given name.
|
<T extends IObject> |
findByString(Class<T> klass,
String field,
String value)
search a given field matching against a String.
|
<T extends IObject> |
get(Class<T> klass,
long id)
lookup an entity by class and id.
|
List<Object[]> |
projection(String query,
Parameters parameters)
|
<T extends IObject> |
refresh(T iObject)
refreshes an entire
IObject graph, recursive loading all data for
the managed instances in the graph from the database. |
<T extends IObject> T get(Class<T> klass, long id) throws ValidationException
klass
- the type of the entity. Not null.id
- the entity's idValidationException
- if the id doesn't exist.<T extends IObject> T find(Class<T> klass, long id)
klass
- klass the type of the entity. Not null.id
- the entity's id<T extends IObject> List<T> findAll(Class<T> klass, Filter filter)
klass
- entity type to be searched. Not null.filter
- filters the result set. Can be null.<T extends IObject> T findByExample(T example) throws ApiUsageException
id
field. For
that, use find(Class, long)
, get(Class, long)
,
findByQuery(String, Parameters)
, or
findAllByQuery(String, Parameters)
example
- Non-null example object.ApiUsageException
- if more than one result is return.<T extends IObject> List<T> findAllByExample(T example, 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 IObject> T findByString(Class<T> klass, String field, String value) throws 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.ApiUsageException
- if more than one result.<T extends IObject> List<T> findAllByString(Class<T> klass, String field, String stringValue, boolean caseSensitive, 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.stringValue
- String used for search. Not null.caseSensitive
- whether to use LIKE or ILIKEfilter
- filters the result set. Can be null.<T extends IObject> T findByQuery(String queryName, Parameters parameters) throws 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
ValidationException
<T extends IObject> List<T> findAllByQuery(String queryName, 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 IObject> List<T> findAllByFullText(Class<T> type, String query, 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.filter
can be used to limit the number
of results returned (Filter.limit
) or the
user for who the results will be found (Filter.owner()
).IObject
instances. Never null.List<Object[]> projection(String query, 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 IObject> T refresh(T iObject) throws 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 databaseIObject
graph (with possible additions and
deletions) which is in-sync with the database.ApiUsageException
- if any non-managed entities are found.
Version: 5.2.4-ice35-b23
Copyright © 2016 The University of Dundee & Open Microscopy Environment. All Rights Reserved.