September 2019
Intermediate to advanced
462 pages
11h 3m
English
Seeing the H2 library in the classpath, Spring has already configured the database. We need to define an entity class that represents data that will be stored in a table in the database.
Again, if we were using Java, we’d write the Task entity class like so:
| | //Java code only for comparison purpose |
| | package com.agiledeveloper.todo; |
| | |
| | import javax.persistence.*; |
| | |
| | @Entity |
| | public class Task { |
| | @Id @GeneratedValue private Long id; |
| | private String description; |
| | |
| | public Long getId() { return id; } |
| | |
| | public String getDescription() { return description; } |
| | } |
Instead, we’ll write that code using Kotlin. Create a new file todo/src/main/kotlin/com/agiledeveloper/todo/Task.kt and add the following ...
Read now
Unlock full access