Creating models

Here, we are going to model the data we have identified into suitable entity classes that can be introspected by Spring Boot to build a suitable database schema. The first model we will concern ourselves with is the user model. Create a package named models under the com.example.messenger.api package. Create a User.kt file within the package and input the following code:

package com.example.messenger.api.modelsimport org.hibernate.validator.constraints.Lengthimport org.springframework.format.annotation.DateTimeFormatimport java.time.Instantimport java.util.*import javax.persistence.*import javax.validation.constraints.Patternimport javax.validation.constraints.Size@Entity@Table(name = "`user`")@EntityListeners(UserListener:: ...

Get Kotlin Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.