Class MovieDAOImpl


  • public class MovieDAOImpl
    extends Object
    • Field Detail

      • log

        private static final org.slf4j.Logger log
    • Constructor Detail

      • MovieDAOImpl

        public MovieDAOImpl()
    • Method Detail

      • setEntityManager

        public void setEntityManager​(EntityManager em)
      • createQuery

        protected <T> MovieDAOImpl.QueryLogger<T> createQuery​(String jpaql,
                                                              Class<T> resultClass)
        Helper method to log the JPAQL portion of the query.
        Parameters:
        jpaql -
        resultClass -
        Returns:
      • getKevinBacon

        public Person getKevinBacon()
        Returns a Person instance for the Kevin Bacon actor who played in Tremors.
        Returns:
      • oneStepFromPerson0

        public List<Person> oneStepFromPerson0​(Person p,
                                               Integer offset,
                                               Integer limit)
        Find people who are 1 step from Kevin Bacon.
        Parameters:
        p -
        offset -
        limit -
        Returns:
      • oneStepFromPersonByDAO

        public Collection<Person> oneStepFromPersonByDAO​(Person p)
        Find people who are 1 step from Person.
        Parameters:
        p -
        offset -
        limit -
        orderBy -
        Returns:
      • oneStepFromPersonByDB

        public List<Person> oneStepFromPersonByDB​(Person p)
        Find people who are 1 step from Person.
        Parameters:
        p -
        offset -
        limit -
        orderBy -
        Returns:
      • getMovies

        public List<Movie> getMovies​(Integer offset,
                                     Integer limit,
                                     String orderBy)
        Returns a bulk, unordered page of movies. This will cause a full table scan since there is no reason to consult the index.
        Parameters:
        offset -
        limit -
        orderBy -
        Returns:
      • getMoviesByRatingUpperFunction

        public List<Movie> getMoviesByRatingUpperFunction​(MovieRating rating,
                                                          Integer offset,
                                                          Integer limit)
        Returns an unordered page of movies matching the supplied rating -- but calling upper() on the DB value. This will cause an index to be bypassed except for an upper() function index.
        Parameters:
        rating -
        offset -
        limit -
        Returns:
      • getMoviesByRatingLowerFunction

        public List<Movie> getMoviesByRatingLowerFunction​(MovieRating rating,
                                                          Integer offset,
                                                          Integer limit)
        Returns an unordered page of movies matching the supplied rating -- but calling lower() on the DB value. This will cause an index to be bypassed except for a lower() function index.
        Parameters:
        rating -
        offset -
        limit -
        Returns:
      • getMoviesByRatingValue

        public List<Movie> getMoviesByRatingValue​(MovieRating rating,
                                                  Integer offset,
                                                  Integer limit,
                                                  String orderBy)
        Returns an unordered page of movies matching the supplied rating -- without calling any function()s on the stored data. If the column contains an index, it will be used.
        Parameters:
        rating -
        offset -
        limit -
        orderBy -
        Returns:
      • getMoviesLikeTitle

        public List<Movie> getMoviesLikeTitle​(String title,
                                              Integer offset,
                                              Integer limit,
                                              String orderBy)
        Returns an unordered page of movies that have a title "like" the one passed in. Note the difference in index behavior when there is a wildcard at the beginning or end of the searched title
        Parameters:
        title -
        offset -
        limit -
        orderBy -
        Returns:
      • getMoviesEqualsTitle

        public List<Movie> getMoviesEqualsTitle​(String title,
                                                Integer offset,
                                                Integer limit)
        Returns movies exactly matching the provided title.
        Parameters:
        title -
        offset -
        limit -
        Returns:
      • getRatingsByTitle

        public List<String> getRatingsByTitle​(String title,
                                              Integer offset,
                                              Integer limit,
                                              String orderBy)
        Returns a list of ratings for movies that exactly match the provided title.
        Parameters:
        title -
        offset -
        limit -
        orderBy -
        Returns:
      • getRatingsLikeTitle

        public List<String> getRatingsLikeTitle​(String title,
                                                Integer offset,
                                                Integer limit,
                                                String orderBy)
        Returns ratings that match the title like criteria.
        Parameters:
        title -
        offset -
        limit -
        orderBy -
        Returns:
      • getTitlesByRating

        public List<String> getTitlesByRating​(MovieRating rating,
                                              Integer offset,
                                              Integer limit)
        Returns an unordered page of titles that match a specified rating. This query will be impacted by a presence of an index on the rating column and the presence of the title column with the rating column as a part of a composite index.
        Parameters:
        rating -
        offset -
        limit -
        Returns:
      • getMovieById

        public Movie getMovieById​(String id)
      • getMovieByIdUnfetched

        public Movie getMovieByIdUnfetched​(String id)
      • getMovieFetchedByIdFetched

        public Movie getMovieFetchedByIdFetched​(String id)
      • getMovieCastCountByDAORelation

        public int getMovieCastCountByDAORelation​(String movieId)
      • getMovieCastCountByDAO

        public int getMovieCastCountByDAO​(String movieId)
      • getMovieCastCountByDB

        public int getMovieCastCountByDB​(String movieId)
      • getCastCountForMovie

        public int getCastCountForMovie​(String movieId)