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 ome.model.IObject> |
find(java.lang.Class<T> klass,
long id)
lookup an entity by class and id.
|
<T extends ome.model.IObject> |
findAll(java.lang.Class<T> klass,
ome.parameters.Filter filter)
lookup all entities that belong to this class and match filter.
|
<T extends ome.model.IObject> |
findAllByExample(T example,
ome.parameters.Filter filter)
search based on provided example entity.
|
<T extends ome.model.IObject> |
findAllByFullText(java.lang.Class<T> type,
java.lang.String query,
ome.parameters.Parameters parameters)
executes a full text search based on Lucene.
|
<T extends ome.model.IObject> |
findAllByQuery(java.lang.String queryName,
ome.parameters.Parameters parameters)
executes the stored query with the given name.
|
<T extends ome.model.IObject> |
findAllByString(java.lang.Class<T> klass,
java.lang.String field,
java.lang.String stringValue,
boolean caseSensitive,
ome.parameters.Filter filter)
search a given field matching against a String.
|
<T extends ome.model.IObject> |
findByExample(T example)
search based on provided example entity.
|
<T extends ome.model.IObject> |
findByQuery(java.lang.String queryName,
ome.parameters.Parameters parameters)
executes the stored query with the given name.
|
<T extends ome.model.IObject> |
findByString(java.lang.Class<T> klass,
java.lang.String field,
java.lang.String value)
search a given field matching against a String.
|
<T extends ome.model.IObject> |
get(java.lang.Class<T> klass,
long id)
lookup an entity by class and id.
|
java.util.List<java.lang.Object[]> |
projection(java.lang.String query,
ome.parameters.Parameters parameters)
Return a list of Java
Object instances (not IObject
instances). |
<T extends ome.model.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 ome.model.IObject> T get(java.lang.Class<T> klass, long id) throws ome.conditions.ValidationException
klass
- the type of the entity. Not null.id
- the entity's idome.conditions.ValidationException
- if the id doesn't exist.<T extends ome.model.IObject> T find(java.lang.Class<T> klass, long id)
klass
- klass the type of the entity. Not null.id
- the entity's id<T extends ome.model.IObject> java.util.List<T> findAll(java.lang.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> java.util.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(java.lang.Class<T> klass, java.lang.String field, java.lang.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> java.util.List<T> findAllByString(java.lang.Class<T> klass, java.lang.String field, java.lang.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.stringValue
- 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(java.lang.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> java.util.List<T> findAllByQuery(java.lang.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> java.util.List<T> findAllByFullText(java.lang.Class<T> type, java.lang.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.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.java.util.List<java.lang.Object[]> projection(java.lang.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 databaseIObject
graph (with possible additions and
deletions) which is in-sync with the database.ome.conditions.ApiUsageException
- if any non-managed entities are found.