Package ome.logic

Class 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
    • 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 a HibernateCallback
      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>
      T
      findByExample​(T example)  
      <T extends ome.model.IObject>
      T
      findByQuery​(java.lang.String queryName, ome.parameters.Parameters params)  
      <T extends ome.model.IObject>
      T
      findByString​(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 method initialize 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 a Filter to a Criteria instance.
      java.util.List<java.lang.Object[]> projection​(java.lang.String query, ome.parameters.Parameters p)  
      <T extends ome.model.IObject>
      T
      refresh​(T iObject)  
      void setAnalyzer​(java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer)  
      void setTimeoutSetter​(TimeoutSetter timeoutSetter)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • analyzer

        protected java.lang.Class<? extends org.apache.lucene.analysis.Analyzer> analyzer
    • Constructor Detail

      • QueryImpl

        public QueryImpl()
    • 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 interface ome.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 interface LocalQuery
      • 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 interface LocalQuery
      • clear

        @Transactional(readOnly=false)
        public void clear()
        Specified by:
        clear in interface LocalQuery
      • initialize

        public void initialize​(java.lang.Object obj)
        Description copied from interface: LocalQuery
        Uses the Hibernate static method initialize to prepare an object for shipping over the wire. It is better to do this in your queries.
        Specified by:
        initialize in interface LocalQuery
        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 interface LocalQuery
        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 interface LocalQuery
        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 a HibernateCallback
        Specified by:
        execute in interface LocalQuery
        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 interface LocalQuery
        Parameters:
        query - A subclass of the Query 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 interface ome.api.IQuery
        Throws:
        ome.conditions.ValidationException
      • find

        public ome.model.IObject find​(java.lang.Class klass,
                                      long id)
        Specified by:
        find in interface ome.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 interface ome.api.IQuery
      • findByExample

        public <T extends ome.model.IObject> T findByExample​(T example)
                                                      throws ome.conditions.ApiUsageException
        Specified by:
        findByExample in interface ome.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 interface ome.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 interface ome.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 interface ome.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 interface ome.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 interface ome.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 interface ome.api.IQuery
      • projection

        public java.util.List<java.lang.Object[]> projection​(java.lang.String query,
                                                             ome.parameters.Parameters p)
        Specified by:
        projection in interface ome.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 interface ome.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 a Filter to a Criteria instance.
        Parameters:
        c - a criteria instance
        f - a filter to limit a query