package cz.muni.fi.pa165.entity;

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javassist.bytecode.Opcode;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;


/**
 * Entity representing a collection of books in a library
 * 
 * @author Jakub Peschel
 * @email jakub.peschel@studentagency.cz
 */
public class BookCollection {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private String name;

    @Column
    @ManyToMany
    private Set<Book> books = new HashSet<>();
    
    //<editor-fold defaultstate="collapsed" desc="GET/SET">
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Set<Book> getBooks() {
        return Collections.unmodifiableSet(books);
    }
    
    public void addBook(Book books) {
        this.books.add(books);
    }
    
    //</editor-fold>

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + Objects.hashCode(this.id);
        hash = 37 * hash + Objects.hashCode(this.name);
        hash = 37 * hash + Objects.hashCode(this.books);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj instanceof BookCollection) {
            return false;
        }
        final BookCollection other = (BookCollection) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (!Objects.equals(this.name, other.name)) {
            return false;
        }
        if (!Objects.equals(this.books, other.books)) {
            return false;
        }
        return true;
    }
    
    
}

@@ -127,24 +127,25 @@
 a.util.Set;%0A
+%0A
 import javas
@@ -147,29 +147,28 @@
 java
-ssist.bytecode.Opcode
+x.persistence.Column
 ;%0Aim
@@ -182,38 +182,38 @@
 vax.persistence.
-Column
+Entity
 ;%0Aimport javax.p
@@ -412,17 +412,16 @@
 brary%0A *
- 
 %0A * @aut
@@ -483,16 +483,24 @@
 .cz%0A */%0A
+@Entity%0A
 public c
@@ -739,20 +739,16 @@
 et%3C%3E();%0A
-    
 %0A    //%3C
@@ -1131,28 +1131,24 @@
 oks);%0A    %7D%0A
-    
 %0A    public 
@@ -1207,28 +1207,24 @@
 oks);%0A    %7D%0A
-    
 %0A    //%3C/edi
@@ -2049,16 +2049,8 @@
   %7D%0A
-    %0A    
+%0A
 %0A%7D%0A

Add missing @Entity annotation