Example #1
0
  @Override
  public List<Visit> resultSetToList(ResultSet rs) throws SQLException {
    // TODO Auto-generated method stub
    List<Visit> visits = new ArrayList<Visit>();
    while (rs.next()) {
      Visit visit = new Visit();
      int id = rs.getInt("id");
      String user_id = rs.getString("user_id");
      int theme_id = rs.getInt("theme_id");
      Date start_time = rs.getTimestamp("start_time");

      User user = userDao.find(user_id);
      Theme theme = themeDao.find(theme_id);

      visit.setId(id);
      visit.setUser(user);
      visit.setTheme(theme);
      visit.setStart_time(start_time);

      visits.add(visit);
    }
    return visits;
  }
Example #2
0
 @Override
 public int add(Visit visit) {
   // TODO Auto-generated method stub
   String sql = "INSERT INTO visit_log(user_id, theme_id, start_time) VALUES(?, ?, ?)";
   return add(sql, visit.getUser().getUser_id(), visit.getTheme().getId(), visit.getStart_time());
 }