Skip to content

Instantly share code, notes, and snippets.

@namila007
Last active March 28, 2019 04:51
Show Gist options
  • Save namila007/fc118a5c85c372587aa4c856a0cc62ee to your computer and use it in GitHub Desktop.
Save namila007/fc118a5c85c372587aa4c856a0cc62ee to your computer and use it in GitHub Desktop.
REST Springboot tutorial
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "book")
public class Book implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "name")
@NotNull
private String name;
@ManyToOne( fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "author_id", nullable = false)
//@JsonBackReference("author")
private Author author;
@ManyToOne( fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@JoinColumn(name = "publisher_id", nullable = false)
//@JsonBackReference("publisher")
private Publisher publisher;
@NotNull
@Column(name = "price")
private double price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment