diff --git a/src/main/java/com/ankurm/sdjpa4demo/domain/Book.java b/src/main/java/com/ankurm/sdjpa4demo/domain/Book.java new file mode 100644 index 0000000..1db085f --- /dev/null +++ b/src/main/java/com/ankurm/sdjpa4demo/domain/Book.java @@ -0,0 +1,37 @@ +package com.ankurm.sdjpa4demo.domain; + +import jakarta.persistence.*; +import java.math.BigDecimal; + +@Entity +public class Book { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String title; + + private BigDecimal price; + + @ManyToOne(fetch = FetchType.LAZY) + private Author author; + + protected Book() { } + + public Book(String title, BigDecimal price, Author author) { + this.title = title; + this.price = price; + this.author = author; + } + + public Long getId() { return id; } + public String getTitle() { return title; } + public BigDecimal getPrice() { return price; } + public Author getAuthor() { return author; } + + @Override + public String toString() { + return "Book{title='" + title + "', price=" + price + "}"; + } +}