|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectome.logic.AbstractLevel1Service
ome.logic.QueryImpl
@Transactional(readOnly=true) public class QueryImpl
Provides methods for directly querying object graphs.
Field Summary | |
---|---|
protected Class<? extends Analyzer> |
analyzer
|
Fields inherited from class ome.logic.AbstractLevel1Service |
---|
queryFactory, sessionFactory |
Constructor Summary | |
---|---|
QueryImpl()
|
Method Summary | ||
---|---|---|
boolean |
checkProperty(String type,
String property)
Checks if a property is defined on a mapped Hibernate type. |
|
boolean |
checkType(String type)
Checks if a type has been mapped in Hibernate. |
|
void |
clear()
|
|
boolean |
contains(Object obj)
Tests if an object is currently contained in the session. |
|
void |
evict(Object obj)
Removes an object graph from the session. |
|
|
execute(org.springframework.orm.hibernate3.HibernateCallback callback)
Executes a HibernateCallback |
|
|
execute(Query<T> query)
Executes a locally defined Query. |
|
ome.model.IObject |
find(Class 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 params)
executes a full text search based on Lucene. |
|
|
findAllByQuery(String queryName,
ome.parameters.Parameters params)
executes the stored query with the given name. |
|
|
findAllByString(Class<T> klass,
String fieldName,
String value,
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 params)
executes the stored query with the given name. |
|
|
findByString(Class<T> klass,
String fieldName,
String value)
search a given field matching against a String. |
|
ome.model.IObject |
get(Class klass,
long id)
lookup an entity by class and id. |
|
Class<? extends ServiceInterface> |
getServiceInterface()
|
|
void |
initialize(Object obj)
Uses the Hibernate static method initialize to prepare an
object for shipping over the wire. |
|
protected void |
parseFilter(org.hibernate.Criteria c,
ome.parameters.Filter f)
responsible for applying the information provided in a Filter to a org.hibernate.Critieria
instance. |
|
|
refresh(T iObject)
refreshes an entire IObject graph, recursive loading all data for
the managed instances in the graph from the database. |
|
void |
setAnalyzer(Class<? extends Analyzer> analyzer)
|
Methods inherited from class ome.logic.AbstractLevel1Service |
---|
getBeanHelper, getQueryFactory, getSessionFactory, selfConfigure, setQueryFactory, setSessionFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Class<? extends Analyzer> analyzer
Constructor Detail |
---|
public QueryImpl()
Method Detail |
---|
public void setAnalyzer(Class<? extends Analyzer> analyzer)
public Class<? extends ServiceInterface> getServiceInterface()
getServiceInterface
in interface SelfConfigurableService
@Transactional(readOnly=false) public boolean contains(Object obj)
LocalQuery
contains
in interface LocalQuery
@Transactional(readOnly=false) public void evict(Object obj)
LocalQuery
evict
in interface LocalQuery
@Transactional(readOnly=false) public void clear()
clear
in interface LocalQuery
public void initialize(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(String type)
LocalQuery
checkType
in interface LocalQuery
type
- String representation of a full-qualified Hibernate-mapped
type.
@Transactional(propagation=SUPPORTS) public boolean checkProperty(String type, 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 ome.model.IObject get(Class klass, long id) throws ome.conditions.ValidationException
IQuery
get
in interface IQuery
klass
- the type of the entity. Not null.id
- the entity's id
ome.conditions.ValidationException
- if the id doesn't exist.IQuery.get(java.lang.Class, long)
,
Session.load(java.lang.Class, java.io.Serializable)
public ome.model.IObject find(Class klass, long id)
IQuery
find
in interface IQuery
klass
- klass the type of the entity. Not null.id
- the entity's id
IQuery.find(java.lang.Class, long)
,
Session.get(java.lang.Class, java.io.Serializable)
public <T extends ome.model.IObject> List<T> findAll(Class<T> klass, ome.parameters.Filter filter)
IQuery
findAll
in interface IQuery
klass
- entity type to be searched. Not null.filter
- filters the result set. Can be null.
ome.api.IQuery#getByClass(java.lang.Class)
public <T extends ome.model.IObject> T findByExample(T example) throws ome.conditions.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.
ome.conditions.ApiUsageException
- if more than one result is return.IQuery.findByExample(ome.model.IObject)
public <T extends ome.model.IObject> List<T> findAllByExample(T example, ome.parameters.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.
IQuery.findAllByExample(ome.model.IObject,
ome.parameters.Filter)
public <T extends ome.model.IObject> T findByString(Class<T> klass, String fieldName, String value) throws ome.conditions.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.
ome.conditions.ApiUsageException
- if more than one result.IQuery.findByString(java.lang.Class, java.lang.String,
java.lang.String)
public <T extends ome.model.IObject> List<T> findAllByString(Class<T> klass, String fieldName, String value, boolean caseSensitive, ome.parameters.Filter filter) throws ome.conditions.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.caseSensitive
- whether to use LIKE or ILIKEfilter
- filters the result set. Can be null.
ome.conditions.ApiUsageException
IQuery.findAllByString(java.lang.Class, java.lang.String,
java.lang.String, boolean, ome.parameters.Filter)
public <T extends ome.model.IObject> T findByQuery(String queryName, ome.parameters.Parameters params) throws ome.conditions.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
ome.conditions.ValidationException
IQuery.findByQuery(java.lang.String,
ome.parameters.Parameters)
public <T extends ome.model.IObject> List<T> findAllByQuery(String queryName, ome.parameters.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
IQuery.findAllByQuery(java.lang.String,
ome.parameters.Parameters)
public <T extends ome.model.IObject> List<T> findAllByFullText(Class<T> type, String query, ome.parameters.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#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.ome.api.IQuery#findAllByFullText(java.lang.String,
ome.parameters.Parameteres)
public <T extends ome.model.IObject> T refresh(T iObject) throws ome.conditions.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 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.IQuery.refresh(IObject)
protected void parseFilter(org.hibernate.Criteria c, ome.parameters.Filter f)
Filter
to a org.hibernate.Critieria
instance.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Version: Beta-4.1.1-r5927-b91
Copyright © 2009 The University of Dundee. All Rights Reserved.