public List<Movie> findAllMovies() {
    ArrayList list = new ArrayList<Movie>();

    Movie movie = new Movie();
    movie.setName("Avatar");
    movie.setDirector("J.Cameron");

    list.add(movie);

    Movie movie1 = new Movie();
    movie1.setName("Titanic");
    movie1.setDirector("J.Cameron");

    list.add(movie1);

    Movie movie2 = new Movie();
    movie2.setName("The Terminator");
    movie2.setDirector("J.Cameron");

    list.add(movie2);

    Movie movie3 = new Movie();
    movie3.setName("Jurassic Park");
    movie3.setDirector("S.Spielberg");

    list.add(movie3);

    return list;
  }
 public void updateMovie() {
   Movie m = em.find(Movie.class, 3, LockModeType.PESSIMISTIC_WRITE);
   em.lock(m, LockModeType.PESSIMISTIC_WRITE);
   m.setName("INCEPTION");
   em.merge(m);
   em.flush();
 }