Package ome.logic
Class QueryImpl
- java.lang.Object
-
- ome.logic.AbstractLevel1Service
-
- ome.logic.QueryImpl
-
- All Implemented Interfaces:
ome.api.IQuery
,LocalQuery
,ome.api.ServiceInterface
,ome.system.SelfConfigurableService
@Transactional(readOnly=true) public class QueryImpl extends AbstractLevel1Service implements LocalQuery
Provides methods for directly querying object graphs.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<? extends org.apache.lucene.analysis.Analyzer>
analyzer
protected TimeoutSetter
timeoutSetter
-
Fields inherited from class ome.logic.AbstractLevel1Service
queryFactory, sessionFactory
-
-
Constructor Summary
Constructors Constructor Description QueryImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Long
aggByQuery(java.lang.String agg, java.lang.String field, java.lang.String query, ome.parameters.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, ome.parameters.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(Query<T> query)
Executes a locally defined Query.<T> T
execute(org.springframework.orm.hibernate3.HibernateCallback callback)
Executes aHibernateCallback
ome.model.IObject
find(java.lang.Class klass, long id)
<T extends ome.model.IObject>
java.util.List<T>findAll(java.lang.Class<T> klass, ome.parameters.Filter filter)
<T extends ome.model.IObject>
java.util.List<T>findAllByExample(T example, ome.parameters.Filter filter)
<T extends ome.model.IObject>
java.util.List<T>findAllByFullText(java.lang.Class<T> type, java.lang.String query, ome.parameters.Parameters params)
<T extends ome.model.IObject>
java.util.List<T>findAllByQuery(java.lang.String queryName, ome.parameters.Parameters params)
<T extends ome.model.IObject>
java.util.List<T>findAllByString(java.lang.Class<T> klass, java.lang.String fieldName, java.lang.String value, boolean caseSensitive, ome.parameters.Filter filter)
<T extends ome.model.IObject>
TfindByExample(T example)
<T extends ome.model.IObject>
TfindByQuery(java.lang.String queryName, ome.parameters.Parameters params)
<T extends ome.model.IObject>
TfindByString(java.lang.Class<T> klass, java.lang.String fieldName, java.lang.String value)
ome.model.IObject
get(java.lang.Class klass, long id)
java.lang.Class<? extends ome.api.ServiceInterface>
getServiceInterface()
void
initialize(java.lang.Object obj)
Uses the Hibernate static methodinitialize
to prepare an object for shipping over the wire.static boolean
isProbablyTimeout(org.springframework.dao.DataAccessResourceFailureException exception)
protected void
parseFilter(org.hibernate.Criteria c, ome.parameters.Filter f)
Responsible for applying the information provided in aFilter
to aCriteria
instance.java.util.List<java.lang.Object[]>
projection(java.lang.String query, ome.parameters.Parameters p)
<T extends ome.model.IObject>
Trefresh(T iObject)
void
setAnalyzer(java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer)
void
setTimeoutSetter(TimeoutSetter timeoutSetter)
-
Methods inherited from class ome.logic.AbstractLevel1Service
getBeanHelper, getQueryFactory, getSessionFactory, selfConfigure, setQueryFactory, setSessionFactory
-
-
-
-
Field Detail
-
analyzer
protected java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer
-
timeoutSetter
protected TimeoutSetter timeoutSetter
-
-
Method Detail
-
setAnalyzer
public void setAnalyzer(java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer)
-
setTimeoutSetter
public void setTimeoutSetter(TimeoutSetter timeoutSetter)
-
getServiceInterface
public java.lang.Class<? extends ome.api.ServiceInterface> getServiceInterface()
- Specified by:
getServiceInterface
in interfaceome.system.SelfConfigurableService
-
contains
@Transactional(readOnly=false) public boolean contains(java.lang.Object obj)
Description copied from interface:LocalQuery
Tests if an object is currently contained in the session.- Specified by:
contains
in interfaceLocalQuery
-
evict
@Transactional(readOnly=false) public void evict(java.lang.Object obj)
Description copied from interface:LocalQuery
Removes an object graph from the session. This allows for non-permanent, mutable calls on the graph.- Specified by:
evict
in interfaceLocalQuery
-
clear
@Transactional(readOnly=false) public void clear()
- Specified by:
clear
in interfaceLocalQuery
-
initialize
public void initialize(java.lang.Object obj)
Description copied from interface:LocalQuery
Uses the Hibernate static methodinitialize
to prepare an object for shipping over the wire. It is better to do this in your queries.- Specified by:
initialize
in interfaceLocalQuery
- See Also:
Hibernate
-
checkType
@Transactional(propagation=SUPPORTS) public boolean checkType(java.lang.String type)
Description copied from interface:LocalQuery
Checks if a type has been mapped in Hibernate.- Specified by:
checkType
in interfaceLocalQuery
- Parameters:
type
- String representation of a full-qualified Hibernate-mapped type.- Returns:
- yes or no.
-
checkProperty
@Transactional(propagation=SUPPORTS) public boolean checkProperty(java.lang.String type, java.lang.String property)
Description copied from interface:LocalQuery
Checks if a property is defined on a mapped Hibernate type.- Specified by:
checkProperty
in interfaceLocalQuery
- Parameters:
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.- Returns:
- yes or no.
-
isProbablyTimeout
public static boolean isProbablyTimeout(org.springframework.dao.DataAccessResourceFailureException exception)
- Parameters:
exception
- a wrapped query exception- Returns:
- if the exception probably was caused by a timeout
-
execute
public <T> T execute(org.springframework.orm.hibernate3.HibernateCallback callback)
Description copied from interface:LocalQuery
Executes aHibernateCallback
- Specified by:
execute
in interfaceLocalQuery
- Parameters:
callback
- An implementation of the HibernateCallback interface.- See Also:
LocalQuery.execute(HibernateCallback)
-
execute
public <T> T execute(Query<T> query)
Description copied from interface:LocalQuery
Executes a locally defined Query.- Specified by:
execute
in interfaceLocalQuery
- Parameters:
query
- A subclass of theQuery
interface.- Returns:
- result of the query See document for the query for the return type.
- See Also:
LocalQuery.execute(Query)
-
get
public ome.model.IObject get(java.lang.Class klass, long id) throws ome.conditions.ValidationException
- Specified by:
get
in interfaceome.api.IQuery
- Throws:
ome.conditions.ValidationException
-
find
public ome.model.IObject find(java.lang.Class klass, long id)
- Specified by:
find
in interfaceome.api.IQuery
-
findAll
public <T extends ome.model.IObject> java.util.List<T> findAll(java.lang.Class<T> klass, ome.parameters.Filter filter)
- Specified by:
findAll
in interfaceome.api.IQuery
-
findByExample
public <T extends ome.model.IObject> T findByExample(T example) throws ome.conditions.ApiUsageException
- Specified by:
findByExample
in interfaceome.api.IQuery
- Throws:
ome.conditions.ApiUsageException
-
findAllByExample
public <T extends ome.model.IObject> java.util.List<T> findAllByExample(T example, ome.parameters.Filter filter)
- Specified by:
findAllByExample
in interfaceome.api.IQuery
-
findByString
public <T extends ome.model.IObject> T findByString(java.lang.Class<T> klass, java.lang.String fieldName, java.lang.String value) throws ome.conditions.ApiUsageException
- Specified by:
findByString
in interfaceome.api.IQuery
- Throws:
ome.conditions.ApiUsageException
-
findAllByString
public <T extends ome.model.IObject> java.util.List<T> findAllByString(java.lang.Class<T> klass, java.lang.String fieldName, java.lang.String value, boolean caseSensitive, ome.parameters.Filter filter) throws ome.conditions.ApiUsageException
- Specified by:
findAllByString
in interfaceome.api.IQuery
- Throws:
ome.conditions.ApiUsageException
-
findByQuery
public <T extends ome.model.IObject> T findByQuery(java.lang.String queryName, ome.parameters.Parameters params) throws ome.conditions.ValidationException
- Specified by:
findByQuery
in interfaceome.api.IQuery
- Throws:
ome.conditions.ValidationException
-
findAllByQuery
public <T extends ome.model.IObject> java.util.List<T> findAllByQuery(java.lang.String queryName, ome.parameters.Parameters params)
- Specified by:
findAllByQuery
in interfaceome.api.IQuery
-
findAllByFullText
public <T extends ome.model.IObject> java.util.List<T> findAllByFullText(java.lang.Class<T> type, java.lang.String query, ome.parameters.Parameters params)
- Specified by:
findAllByFullText
in interfaceome.api.IQuery
-
projection
public java.util.List<java.lang.Object[]> projection(java.lang.String query, ome.parameters.Parameters p)
- Specified by:
projection
in interfaceome.api.IQuery
-
aggByQuery
public java.lang.Long aggByQuery(java.lang.String agg, java.lang.String field, java.lang.String query, ome.parameters.Parameters params)
-
aggMapByQuery
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, ome.parameters.Parameters params)
-
refresh
public <T extends ome.model.IObject> T refresh(T iObject) throws ome.conditions.ApiUsageException
- Specified by:
refresh
in interfaceome.api.IQuery
- Throws:
ome.conditions.ApiUsageException
-
parseFilter
protected void parseFilter(org.hibernate.Criteria c, ome.parameters.Filter f)
Responsible for applying the information provided in aFilter
to aCriteria
instance.- Parameters:
c
- a criteria instancef
- a filter to limit a query
-
-