* models, repos, test * update models and test * updated test location * update test location
60 lines
1.2 KiB
Java
60 lines
1.2 KiB
Java
package com.baeldung.models;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.persistence.CascadeType;
|
|
import javax.persistence.Column;
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.GeneratedValue;
|
|
import javax.persistence.Id;
|
|
import javax.persistence.JoinColumn;
|
|
import javax.persistence.JoinTable;
|
|
import javax.persistence.ManyToMany;
|
|
|
|
@Entity
|
|
public class Author {
|
|
|
|
@Id
|
|
@GeneratedValue
|
|
private long id;
|
|
|
|
@Column(nullable = false)
|
|
private String name;
|
|
|
|
@ManyToMany(cascade = CascadeType.ALL)
|
|
@JoinTable(name = "book_author", joinColumns = @JoinColumn(name = "book_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "author_id", referencedColumnName = "id"))
|
|
private List<Book> books;
|
|
|
|
public Author() {
|
|
}
|
|
|
|
public Author(String name) {
|
|
super();
|
|
this.name = name;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public List<Book> getBooks() {
|
|
return books;
|
|
}
|
|
|
|
public void setBooks(List<Book> books) {
|
|
this.books = books;
|
|
}
|
|
}
|