View difference between Paste ID: Eru8VDig and TaFdeKxh
SHOW: | | - or go back to the newest paste.
1
class Task extends Record[Long, Task] with IdentityGenerator[Long, Task] {
2-
  def this(name: String, description: String, done: Boolean, dueTo: Option[Date], id: Long) = {
2+
  def this(name: String, description: String, done: Boolean, dueTo: Date, id: Long) = {
3
    this()
4
    this.name := name.trim()
5
    this.description := description.trim()
6
    this.dueTo := dueTo
7
    this.done := done
8
    if (id == 0) this.id.setNull else this.id := id
9
  }
10
11
  def PRIMARY_KEY = id
12
  def relation = Task
13
14
  val id = "id".BIGINT.NOT_NULL.AUTO_INCREMENT
15
  val name = "name".VARCHAR(255)
16
  val description = "description".TEXT
17
  val createdAt = "created_at".TIMESTAMP.DEFAULT("current_timestamp")
18
  val dueTo = "due_to".DATE
19
  val done = "done".BOOLEAN.NOT_NULL(false)
20
21
}
22
23-
def apply(name: String, description: String, done: String, dueTo: Option[Date], id: Long) = {
23+
object Task extends Task with Table[Long, Task] {
24-
    var task: Task = null;
24+
  private val taskDbObj = this AS "taskDbObj"
25
26-
      task = Task.get(id).get
26+
  def apply(name: String, description: String, done: String, dueTo: Option[Date], id: Long) = {
27
    if (id > 0) {
28
      val task = Task.get(id).get
29
      task.name := name
30
      task.description := description
31
      task.done := (done == "on")
32
      task.dueTo := dueTo getOrElse (null)
33
      task.id := id
34-
      task = new Task(name, description, done == "on", dueTo getOrElse null, id)
34+
      task
35
    }
36-
    task
36+
37-
  }
37+
      new Task(name, description, done == "on", Some(dueTo), id)
38
    }
39
  }
40
}
41
42
// stacktrace:
43
C:\Users\sveri\git\seiwomisa\seiwomisa\app\models\Task.scala:44: type mismatch;
44
 found   : Some[Option[java.util.Date]]
45
 required: java.util.Date
46
      new Task(name, description, done == "on", Some(dueTo), id)
47
                                                    ^
48
one error found