Class HibernateContactDao

    • Constructor Detail

      • HibernateContactDao

        public HibernateContactDao()
    • Method Detail

      • setSessionFactory

        public void setSessionFactory​(org.hibernate.SessionFactory factory)
        Setter for session factory. Spring will use this to inject the session factory into the dao.
        Parameters:
        factory - hibernate session factory
      • getSession

        protected org.hibernate.Session getSession()
        Helper method for retrieving hibernate session
        Returns:
        hibernate session
      • load

        public Contact load​(long id)
        Load a Contact from the DB, given it's id .
        Specified by:
        load in interface ContactDao
        Parameters:
        id - The id of the Contact to load.
        Returns:
        Contact
      • save

        public Contact save​(Contact contact)
        Save the contact to the DB
        Specified by:
        save in interface ContactDao
        Parameters:
        contact -
        Returns:
        persistent instance of contact
      • delete

        public void delete​(long id)
        Delete a Contact from the DB, given it's id.
        Specified by:
        delete in interface ContactDao
        Parameters:
        id - The id of the Contact to delete.
      • find

        public Iterator<Contact> find​(QueryParam qp,
                                      Contact filter)
        Query the DB, using the supplied query details.
        Specified by:
        find in interface ContactDao
        Parameters:
        qp - Query Parameters to use.
        Returns:
        The results of the query as an Iterator.
      • count

        public int count​(Contact filter)
        Return the number of Contacts in the DB.
        Specified by:
        count in interface ContactDao
        Returns:
        count
      • getUniqueLastNames

        public List<String> getUniqueLastNames()
        Returns a list of unique last names
        Specified by:
        getUniqueLastNames in interface ContactDao
        Returns:
        the list of all unique last names in the database
      • buildFindQuery

        protected org.hibernate.Query buildFindQuery​(QueryParam qp,
                                                     Contact filter,
                                                     boolean count)
        builds a query object to satisfy the provided parameters
        Parameters:
        qp - sorting and paging criteria
        filter - filter criteria
        count - true if this is a query meant to retrieve the number of rows
        Returns:
        query object that satisfies the provided criteria