75 lines
1.4 KiB
Java
75 lines
1.4 KiB
Java
package com.baeldung.models;
|
|
|
|
import java.util.List;
|
|
|
|
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.OneToMany;
|
|
import javax.persistence.OneToOne;
|
|
|
|
import org.springframework.data.rest.core.annotation.RestResource;
|
|
|
|
@Entity
|
|
public class Library {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
|
private long id;
|
|
|
|
@Column
|
|
private String name;
|
|
|
|
@OneToOne
|
|
@JoinColumn(name = "address_id")
|
|
@RestResource(path = "libraryAddress")
|
|
private Address address;
|
|
|
|
@OneToMany(mappedBy = "library")
|
|
private List<Book> books;
|
|
|
|
public Library() {
|
|
}
|
|
|
|
public Library(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 Address getAddress() {
|
|
return address;
|
|
}
|
|
|
|
public void setAddress(Address address) {
|
|
this.address = address;
|
|
}
|
|
|
|
public List<Book> getBooks() {
|
|
return books;
|
|
}
|
|
|
|
public void setBooks(List<Book> books) {
|
|
this.books = books;
|
|
}
|
|
|
|
}
|