예제 #1
0
  public List<Movie> getMoviesByCondition(Movie m) {
    if (m == null) {
      return null;
    }
    Session session = TribusHibernateSessionFactory.currentSession();
    try {

      Criteria c = session.createCriteria(Movie.class);
      if (m.getMovieId() != 0) {
        c.add(Restrictions.eq("movieId", m.getMovieId()));
      }
      if (m.getMovieNameOriginal() != null) {
        c.add(Restrictions.eq("movieNameOriginal", m.getMovieNameOriginal()));
      }

      List<Movie> mo = c.list();
      return mo;

    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
    return null;
  }
예제 #2
0
  public int updateMovieNameOriginal(Movie movie) {
    System.out.println(movie.getMovieId() + "*" + movie.getMovieNameOriginal());
    int result = 0;
    Session session = TribusHibernateSessionFactory.currentSession();
    Transaction tx = session.beginTransaction();

    try {
      session.update(movie);
      // session.flush();
      tx.commit();
      result = 1;
    } catch (Exception e) {
      // TODO: handle exception
      System.out.println(e.getMessage());
      tx.rollback();
    }
    return result;
  }