Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Book {
- @Id
- @GeneratedValue
- private int bookId;
- private String name;
- @OneToMany(mappedBy = "Book")
- private List<Chapter> chapters;
- }
- public class Chapter {
- @Id
- @GeneratedValue
- @ManyToOne
- private int chapterId;
- private String name;
- @JoinColumn(name = "bookId")
- private Book book;
- }
- {
- "id" : "1"
- "name" : "Alice in wonderland"
- }
- {
- "id": "1",
- "name" : "Down the Rabbit Hole"
- }
- {
- "chapterId" : 1,
- "name" : "Down the Rabbit Hole",
- "bookId" : "1"
- }
- chapter = (Chapter) session.get( Chapter.class, chapterId );
- {
- "chapterId" : 1,
- "name": "Down the Rabbit Hole",
- "Book" : {
- "bookId" : "1",
- "name": "Alice in wonderland"
- }
- }
- {
- "name" : "The Pool of Tears",
- "bookId" : "1"
- }
- {
- "name" : "The Pool of Tears",
- "Book" : {
- "bookId" : "1",
- "name" : "Alice in wonderland"
- }
- }
Add Comment
Please, Sign In to add comment