From the course: Learning Spring 6 with Spring Boot 3
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Repositories with Spring Data - Spring Tutorial
From the course: Learning Spring 6 with Spring Boot 3
Repositories with Spring Data
- [Narrator] So now that we have the embedded database set up, let's do a little data access and I can prove to you that that data was loaded as we get through this video. All right, the first thing that I want you to do is I want you to load up in source main resources, go ahead and load that schema.sql file. This is going to give us a template that we are going to use in order to build our object. So now in source main Java in our root package, let's create a new package and we will call it data.entity. And within there we are going to create a new Java Class called Room. Now we need to annotate this with @Entity. And then we are going to do an @Table with a name equal to rooms. Go ahead and import that from Jakarta Persistence. Now what you will notice is is I named the table Rooms and it serves a room object. So now let's go ahead and define that room object. So the first thing we need to do is do an @Id and we will do…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.