package ro.pub.cs.aipi.lab02.entities; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.OneToOne; import javax.persistence.Table; @Entity @Table(name = "bookstore.book") public class Book extends PersistentEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") protected Long id; @Column(name = "title") protected String title; @Column(name = "subtitle") protected String subtitle; @ManyToMany(targetEntity = Writer.class) @JoinTable(name="bookstore.author", joinColumns=@JoinColumn(name="book_id"), inverseJoinColumns=@JoinColumn(name="writer_id")) protected Set writers; @Column(name = "description") protected String description; @Column(name = "edition") protected Long edition; @Column(name = "printing_year") protected Long printingYear; @OneToOne @JoinColumn(name = "collection_id", unique = false, nullable = false, updatable = true) protected Collection collection; @ManyToMany(targetEntity = Category.class) @JoinTable(name="bookstore.category_content", joinColumns=@JoinColumn(name="book_id"), inverseJoinColumns=@JoinColumn(name="category_id")) protected Set categories; // ... }