models, repos, test (#1225)

* models, repos, test

* update models and test

* updated test location

* update test location
This commit is contained in:
lor6
2017-02-26 21:30:47 +02:00
committed by KevinGilmore
parent 7f20437cb0
commit 1a067bc945
9 changed files with 394 additions and 0 deletions
@@ -0,0 +1,70 @@
package com.baeldung.models;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@Entity
public class Book {
@Id
@GeneratedValue
private long id;
@Column(nullable = false)
private String title;
@ManyToOne
@JoinColumn(name = "library_id")
private Library library;
@ManyToMany(mappedBy = "books")
private List<Author> authors;
public Book() {
}
public Book(String title) {
super();
this.title = title;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Library getLibrary() {
return library;
}
public void setLibrary(Library library) {
this.library = library;
}
public List<Author> getAuthors() {
return authors;
}
public void setAuthors(List<Author> authors) {
this.authors = authors;
}
}