From the course: Build Spring Boot Apps with the Kotlin Programming Language

Unlock this course with a free trial

Join today to access over 22,700 courses taught by industry experts.

Persisting data to a database

Persisting data to a database

- [Instructor] Okay, so that is pretty much all we need to do that is specific to Kotlin. The rest of this should be doing very much what you'd expect to do in Java, so what I'd like to do, then, is to create instances of my Seat class when I run that bootstrap method, and then persist those in the database. We'll need to have, I guess, a primary key on our seat, so let's add that in, and actually, I'm going to just tidy this up by putting each of my attributes onto a new line and then the primary key is going to be a Long, which we'll call ID, and of course, in Hibernate, we need to add some annotations to the primary key, and we can do those just as we would in Java. The fact it's in round brackets as part of the primary constructor for our data class, really doesn't matter. We can add in here the at ID annotation, we can have the generated value annotation, and then we'll put in here that the strategy can be generation type auto, and that then should take care of our ID, so that…

Contents