So i have code block similar to this:
public class Task {
private Long id;
private String description;
private Date dueDate;
// getters and setters here
public List<Task> getAllTasks(){
String sql =
"SELECT id, description, duedate " +
"FROM tasks";
try(Connection con = sql2o.open()) {
return con.createQuery(sql).executeAndFetch(Task.class);
}
}
}
(There is also a getID method and getDesc method left out) I am able to run something like this to get the objects in the list it returns:
Task myTask1 = Task.getAllTasks().get(0);
If i try and print the id or desc from it like so
System.out.println(myTask1.getID());
System.out.println(myTask1.getDesc());
I always get 0 and null, which is not the correct values. What do i need to do to get this to work?