@Entity @Table(name = "pets") // note : using JPQL not native SQL named queries public class Pet implements Serializable{ /** * */ private static final long serialVersionUID = -5176917370330952845L; @Id @GeneratedValue(strategy=GenerationType.AUTO) private Integer id; @Column(name="name") private String name; @Column(name="photo") @OneToMany(targetEntity=Photo.class) private ListphotoUrls = new ArrayList<>(); private String petImage; private Listtags = new ArrayList<>(); @Enumerated(EnumType.STRING) private Status status; public Pet() {} public Pet(String name, Listurls, Listtags, Status status) { this.name = name; this.photoUrls = urls; this.tags = tags; this.status = status; } @ManyToOne @JoinColumn(name = "category_id") private Category category; @ManyToOne @JoinColumn(name = "userNaeme") private User user; //LinkedHashSet - O(1) private Set orders = new LinkedHashSet<>(); //// to check need to maintain insertionOrder? public Category getCategory() { return category; } public void setCategory(Category category) { this.category = category; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public List getPhotoUrls() { return photoUrls; } public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } public String getPetImage() { return petImage; } public List getTags() { return tags; } public void setTags(List tags) { this.tags = tags; } public void setOrders(Set orders) { this.orders = orders; } public User getUser() { return this.user; } public void setUser(User user) { this.user = user; } public String getName() { return name; } public void setName(String name) { this.name = name; } protected Set getOrdersInternal() { if (this.orders == null) { this.orders = new HashSet<>(); } return this.orders; } public void setOrdersInternal(Collection orders) { this.orders = new LinkedHashSet<>(orders); } public List getOrders() { List sortedOrders = new ArrayList<>(getOrdersInternal()); PropertyComparator.sort(sortedOrders, new MutableSortDefinition("date", false, false)); return Collections.unmodifiableList(sortedOrders); } public void addOrder(Order order) { getOrdersInternal().add(order); order.setId(this.getId()); } public Status getStatus() { return status; } public void setStatus(Status status) { this.status = status; } public byte[] setPetImage(byte[] bytes) { // TODO Auto-generated method stub return bytes; } }