public void addMovieTx(Integer id, String director, String title, String synopsis) {

    Movie movie = new Movie();

    movie.setId(id);
    movie.setDirector(director);
    movie.setTitle(title);
    movie.setSynopsis(synopsis);

    Movie movie0 = new Movie();

    movie0.setId(101);
    movie0.setDirector("d");
    movie0.setTitle("t");
    movie0.setSynopsis("s");

    Session session = sf.getCurrentSession();

    org.hibernate.Transaction tx = session.beginTransaction();

    try {

      session.save(movie0);
      session.save(movie);

      tx.commit();
    } catch (HibernateException e) {
      System.out.println("Caught an hibernate exception.");
      if (tx != null) {
        System.out.println("Rolling back the transaction.");
        tx.rollback();
      }
    }
  }
  public void addMovie(Integer id, String director, String title, String synopsis) {

    Movie movie = new Movie();

    movie.setId(id);
    movie.setDirector(director);
    movie.setTitle(title);
    movie.setSynopsis(synopsis);

    Session session = sf.getCurrentSession();

    session.beginTransaction();

    session.save(movie);

    session.getTransaction().commit();
  }