So here we are in our lab we asked you to bring in couple of classes from your setup directory like 5.1 course and a test a class. Let's take a look at them. Here's the course, this is the table, it's mapped against course it's an entity. That's an ID, and ID title location that's a version for optimistic locking and it has this student property that we've asked you to annotate. And we have this many to one join column student ID. Okay, so let's go take a look at the data base. So if I look at the course table, you'll see it's got a student ID as one of the columns there it is, right there. So when we say join columns student ID, we're basically saying this student ID in this row on this table is going to map to the table associated with the other end of the relationship in this case, student. So if I open up student and look at it columns this student ID in course will map to the student ID, the primary key in student and either an N1 select or a join will associate these two tables together. So this is the owning side of the relationship because it has the foreign key in the associated table with this entity, there, student ID. Many to one basically means that this course could be associated with many students based off the table relationship between the foreign key and the primary key. So we can have lots of courses with a foreign key of student number one or pointing to student number one on the student table. So that's our owning relationship right there. Now I go back here, I can take a look at student and what we wanted you to add here is a collection of courses and we see this one to many with a couple of things. Orphan removal and cascade type all. When I put this collection in, I also put in getters and setters for it. The cascade all means that all cascade options are active, persist, update, merge, even delete, remove that is. So that means if I bring back a student and add courses to it and then save that student, I commit the transaction in a persistence context. The new course is added to the surrealist result in inserts on the associated course table creating new rows associated with this student on its row in its table. The orphan removal means that if I bring back a student and remove a course the association is broken. And as such, it will formulate a delete operation on the row associated with that course. Okay, so we've got our two annotations done one to many map by student. Well we have to go to the owning side of relationship and we will see a property called student. We're back on the owning side with the foreign key. Sometimes this side is called the reverse side because it doesn't have the foreign key because student is the primary key that the foreign keys are mapped to. Okay, let's take a look at the test class that we gave you and it was called student course test familiar code. I bring back student number one, I add a couple of courses to that student because it's happening within a transaction and I commit it, those courses will indeed be added to that student. My second test is to go and find the student number one and print out all its courses. And since I had two, it should have two courses added to it. And to make my test a little bit repeatable, test number three goes and finds student number one, get his courses and basically clears out that list. The orphan removal should result in delete operations, getting rid of those courses. Remember up here when we added the students here, just by adding them committing the cascade option is going to result in persisting of those courses on the table. All right, then, let's test this student class out and let's see what happens. Run us to unit where we go. Well, I've got a green, but I'm interested in what's being generated. I see the selection of the student, I see the insert, and I see a second insert so that really relates to the cascade all option working. Let's scroll down a little bit further. I see a select student and I see a select on courses, scroll over here. Yes, it's using the foreign key right there. And indeed I get two courses printed out. Last bt not least, I scroll down a little bit further, and I see a select on a student and then I see the orphan removal doing two deletes getting rid of it. So it looks like our cascade and orphan removals have worked. Okay let's try it one more thing or comment out this test. So this time we won't delete the courses. I'll run it, it's prompting me to save it. Okay, let's go to the database and let's go to the table course. And there we are. We are just confirming yet again that we did indeed insert two courses by just adding them to that associated collection in the student class. And the cascade did indeed persisted down into the database upon transaction commit.