Introduction
I am doing a CRUD in my application, everything is perfect however my delete is giving error when compiling
Error
Task.java
package models;
import java.util.*;
import java.util.*;
import play.db.ebean.*;
import play.data.validation.Constraints.*;
import javax.persistence.*;
@Entity
public class Task extends Model{
@Id
public Long id;
@Required
public String tarefas;
public static Finder find = new Finder(Long.class, Task.class);
public static List<Task> all() {
return find.all();
}
public static void create(Task task) {
task.save();
}
public static void delete(Long id) {
find.ref(id).delete();
}
}
Controller
package controllers;
import play.*;
import play.mvc.*;
import play.data.*;
import play.data.Form;
import views.html.*;
import models.*;
public class Application extends Controller {
static Form<Task> taskForm = Form.form(Task.class);
public static Result index() {
return redirect(routes.Application.tasks());
}
public static Result tasks() {
return ok(views.html.index.render(Task.all(), taskForm));
}
public static Result newTask() {
Form<Task> filledForm = taskForm.bindFromRequest();
if(filledForm.hasErrors()){
return badRequest(
index.render(Task.all(), filledForm)
);
}else{
Task.create(filledForm.get());
return redirect(routes.Application.tasks());
}
}
public static Result deleteTask(Long id) {
Task.delete(id);
return redirect(routes.Application.tasks());
}
}