@Transactional(readOnly=true) public class QueryImpl extends AbstractLevel1Service implements LocalQuery
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> |
analyzer |
queryFactory, sessionFactory
Constructor and Description |
---|
QueryImpl() |
Modifier and Type | Method and Description |
---|---|
java.lang.Long |
aggByQuery(java.lang.String agg,
java.lang.String field,
java.lang.String query,
Parameters params) |
java.util.Map<java.lang.String,java.lang.Long> |
aggMapByQuery(java.lang.String agg,
java.lang.String mapKey,
java.lang.String field,
java.lang.String query,
Parameters params) |
boolean |
checkProperty(java.lang.String type,
java.lang.String property)
Checks if a property is defined on a mapped Hibernate type.
|
boolean |
checkType(java.lang.String type)
Checks if a type has been mapped in Hibernate.
|
void |
clear() |
boolean |
contains(java.lang.Object obj)
Tests if an object is currently contained in the session.
|
void |
evict(java.lang.Object obj)
Removes an object graph from the session.
|
<T> T |
execute(org.springframework.orm.hibernate3.HibernateCallback callback)
Executes a
HibernateCallback |
<T> T |
execute(Query<T> query)
Executes a locally defined Query.
|
IObject |
find(java.lang.Class klass,
long id)
lookup an entity by class and id.
|
<T extends IObject> |
findAll(java.lang.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(java.lang.Class<T> type,
java.lang.String query,
Parameters params)
executes a full text search based on Lucene.
|
<T extends IObject> |
findAllByQuery(java.lang.String queryName,
Parameters params)
executes the stored query with the given name.
|
<T extends IObject> |
findAllByString(java.lang.Class<T> klass,
java.lang.String fieldName,
java.lang.String value,
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(java.lang.String queryName,
Parameters params)
executes the stored query with the given name.
|
<T extends IObject> |
findByString(java.lang.Class<T> klass,
java.lang.String fieldName,
java.lang.String value)
search a given field matching against a String.
|
IObject |
get(java.lang.Class klass,
long id)
lookup an entity by class and id.
|
java.lang.Class<? extends ServiceInterface> |
getServiceInterface() |
void |
initialize(java.lang.Object obj)
Uses the Hibernate static method
initialize to prepare an
object for shipping over the wire. |
protected void |
parseFilter(org.hibernate.Criteria c,
Filter f)
Responsible for applying the information provided in a
Filter to a Criteria
instance. |
java.util.List<java.lang.Object[]> |
projection(java.lang.String query,
Parameters p)
Return a list of Java
Object instances (not IObject
instances). |
<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. |
void |
setAnalyzer(java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer) |
getBeanHelper, getQueryFactory, getSessionFactory, selfConfigure, setQueryFactory, setSessionFactory
protected java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer
public void setAnalyzer(java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer)
public java.lang.Class<? extends ServiceInterface> getServiceInterface()
getServiceInterface
in interface SelfConfigurableService
@Transactional(readOnly=false) public boolean contains(java.lang.Object obj)
LocalQuery
contains
in interface LocalQuery
@Transactional(readOnly=false) public void evict(java.lang.Object obj)
LocalQuery
evict
in interface LocalQuery
@Transactional(readOnly=false) public void clear()
clear
in interface LocalQuery
public void initialize(java.lang.Object obj)
LocalQuery
initialize
to prepare an
object for shipping over the wire.
It is better to do this in your queries.initialize
in interface LocalQuery
Hibernate
@Transactional(propagation=SUPPORTS) public boolean checkType(java.lang.String type)
LocalQuery
checkType
in interface LocalQuery
type
- String representation of a full-qualified Hibernate-mapped
type.@Transactional(propagation=SUPPORTS) public boolean checkProperty(java.lang.String type, java.lang.String property)
LocalQuery
checkProperty
in interface LocalQuery
type
- String representation of a full-qualified Hibernate-mapped
type.property
- Property as defined in Hibernate NOT the public final static
Strings on our IObject classes.public <T> T execute(org.springframework.orm.hibernate3.HibernateCallback callback)
LocalQuery
HibernateCallback
execute
in interface LocalQuery
callback
- An implementation of the HibernateCallback interface.LocalQuery.execute(HibernateCallback)
public <T> T execute(Query<T> query)
LocalQuery
execute
in interface LocalQuery
query
- A subclass of the Query
interface.LocalQuery.execute(Query)
public IObject get(java.lang.Class klass, long id) throws ValidationException
IQuery
get
in interface IQuery
klass
- the type of the entity. Not null.id
- the entity's idValidationException
- if the id doesn't exist.public IObject find(java.lang.Class klass, long id)
IQuery
public <T extends IObject> java.util.List<T> findAll(java.lang.Class<T> klass, Filter filter)
IQuery
public <T extends IObject> T findByExample(T example) throws ApiUsageException
IQuery
id
field. For
that, use IQuery.find(Class, long)
, IQuery.get(Class, long)
,
IQuery.findByQuery(String, Parameters)
, or
IQuery.findAllByQuery(String, Parameters)
findByExample
in interface IQuery
example
- Non-null example object.ApiUsageException
- if more than one result is return.public <T extends IObject> java.util.List<T> findAllByExample(T example, Filter filter)
IQuery
Filter
object.
Note: findAllbyExample does not operate on the id
field.
For that, use IQuery.find(Class, long)
, IQuery.get(Class, long)
,
IQuery.findByQuery(String, Parameters)
, or
IQuery.findAllByQuery(String, Parameters)
findAllByExample
in interface IQuery
example
- Non-null example object.filter
- filters the result set. Can be null.public <T extends IObject> T findByString(java.lang.Class<T> klass, java.lang.String fieldName, java.lang.String value) throws ApiUsageException
IQuery
findByString
in interface IQuery
klass
- type of entity to be searchedfieldName
- 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.public <T extends IObject> java.util.List<T> findAllByString(java.lang.Class<T> klass, java.lang.String fieldName, java.lang.String value, boolean caseSensitive, Filter filter) throws ApiUsageException
IQuery
Filter
instance.findAllByString
in interface IQuery
klass
- type of entity to be searched. Not null.fieldName
- 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.ApiUsageException
public <T extends IObject> T findByQuery(java.lang.String queryName, Parameters params) throws ValidationException
IQuery
findByQuery
in interface IQuery
queryName
- String identifier of the query to executeparams
- array of QueryParameter
. Not null. The
QueryParameter.name
field maps to a field-name which
is then matched against the QueryParameter.value
ValidationException
public <T extends IObject> java.util.List<T> findAllByQuery(java.lang.String queryName, Parameters params)
IQuery
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.
findAllByQuery
in interface IQuery
queryName
- String identifier of the query to execute. Not null.params
- array of QueryParameter
. The
QueryParameter.name
field maps to a field-name which
is then matched against the QueryParameter.value
public <T extends IObject> java.util.List<T> findAllByFullText(java.lang.Class<T> type, java.lang.String query, Parameters params)
IQuery
findAllByFullText
in interface IQuery
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.params
- 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.public java.util.List<java.lang.Object[]> projection(java.lang.String query, Parameters p)
IQuery
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:
projection
in interface IQuery
public java.lang.Long aggByQuery(java.lang.String agg, java.lang.String field, java.lang.String query, Parameters params)
public java.util.Map<java.lang.String,java.lang.Long> aggMapByQuery(java.lang.String agg, java.lang.String mapKey, java.lang.String field, java.lang.String query, Parameters params)
public <T extends IObject> T refresh(T iObject) throws ApiUsageException
IQuery
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.refresh
in interface IQuery
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.4.10-ice35-b105
Copyright © 2019 The University of Dundee & Open Microscopy Environment. All Rights Reserved.