Class AbstractDaoHibernate<T,​K extends Serializable>

    • Constructor Detail

      • AbstractDaoHibernate

        public AbstractDaoHibernate​(Class<T> entityClass)
    • Method Detail

      • initDao

        protected void initDao()
                        throws Exception
        Overrides:
        initDao in class org.springframework.dao.support.DaoSupport
        Throws:
        Exception
      • lock

        public void lock()
        This is used to lock the table in order to implement upsert type operations
        Specified by:
        lock in interface OnmsDao<T,​K extends Serializable>
      • merge

        public void merge​(T entity)
      • find

        public List<T> find​(String query)

        find

        Parameters:
        query - a String object.
        Returns:
        a List object.
      • findObjects

        public <S> List<S> findObjects​(Class<S> clazz,
                                       String query,
                                       Object... values)

        findObjects

        Type Parameters:
        S - a S object.
        Parameters:
        clazz - a Class object.
        query - a String object.
        values - a Object object.
        Returns:
        a List object.
      • queryInt

        protected int queryInt​(String query)

        queryInt

        Parameters:
        query - a String object.
        Returns:
        a int.
      • queryInt

        protected int queryInt​(String queryString,
                               Object... args)

        queryInt

        Parameters:
        queryString - a String object.
        args - a Object object.
        Returns:
        a int.
      • findUnique

        protected T findUnique​(String queryString,
                               Object... args)
        Return a single instance that matches the query string, or null if the query returns no results.
      • delete

        public void delete​(T entity)
                    throws org.springframework.dao.DataAccessException

        delete

        Specified by:
        delete in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        entity - a T object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • delete

        public void delete​(K key)
                    throws org.springframework.dao.DataAccessException

        delete

        Specified by:
        delete in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        key - a K object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • deleteAll

        public void deleteAll​(Collection<T> entities)
                       throws org.springframework.dao.DataAccessException

        deleteAll

        Parameters:
        entities - a Collection object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • findAll

        public List<T> findAll()
                        throws org.springframework.dao.DataAccessException

        findAll

        Specified by:
        findAll in interface OnmsDao<T,​K extends Serializable>
        Returns:
        a List object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • buildHibernateCallback

        protected <T> org.springframework.orm.hibernate3.HibernateCallback<List<T>> buildHibernateCallback​(Criteria criteria)
      • countMatching

        public int countMatching​(Criteria criteria)
                          throws org.springframework.dao.DataAccessException
        Specified by:
        countMatching in interface OnmsDao<T,​K extends Serializable>
        Throws:
        org.springframework.dao.DataAccessException
      • findMatching

        public List<T> findMatching​(OnmsCriteria onmsCrit)
                             throws org.springframework.dao.DataAccessException
        Throws:
        org.springframework.dao.DataAccessException
      • countMatching

        public int countMatching​(OnmsCriteria onmsCrit)
                          throws org.springframework.dao.DataAccessException
        Throws:
        org.springframework.dao.DataAccessException
      • bulkDelete

        public int bulkDelete​(String hql,
                              Object[] values)
                       throws org.springframework.dao.DataAccessException

        bulkDelete

        Parameters:
        hql - a String object.
        values - an array of Object objects.
        Returns:
        a int.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • get

        public T get​(K id)
              throws org.springframework.dao.DataAccessException

        get

        Specified by:
        get in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        id - a K object.
        Returns:
        a T object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • load

        public T load​(K id)
               throws org.springframework.dao.DataAccessException

        load

        Specified by:
        load in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        id - a K object.
        Returns:
        a T object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • save

        public K save​(T entity)
               throws org.springframework.dao.DataAccessException

        save

        Specified by:
        save in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        entity - a T object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • saveOrUpdate

        public void saveOrUpdate​(T entity)
                          throws org.springframework.dao.DataAccessException

        saveOrUpdate

        Specified by:
        saveOrUpdate in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        entity - a T object.
        Throws:
        org.springframework.dao.DataAccessException - if any.
      • update

        public void update​(T entity)
                    throws org.springframework.dao.DataAccessException

        update

        Specified by:
        update in interface OnmsDao<T,​K extends Serializable>
        Parameters:
        entity - a T object.
        Throws:
        org.springframework.dao.DataAccessException - if any.