Пример #1
0
 @Override
 public boolean equals(Object otherCategory) {
   if (!(otherCategory instanceof Category)) {
     return false;
   } else {
     Category newCategory = (Category) otherCategory;
     return this.getName().equals(newCategory.getName());
   }
 }
Пример #2
0
 public void addCategory(Category category) {
   try (Connection con = DB.sql2o.open()) {
     String sql =
         "INSERT INTO categories_tasks (category_id, task_id) VALUES (:category_id, :task_id)";
     con.createQuery(sql)
         .addParameter("category_id", category.getId())
         .addParameter("task_id", this.getId())
         .executeUpdate();
   }
 }