2019年8月15日 星期四

Spring Data Jpa - Hibernate 一對一 單向 跟一對多 單向

 一對一 單向
package com.example.demo.dto;
import com.example.demo.model.Student;
public class PersonDTO2 {

    private Long id;    private String  author;    private int  price;    private String title;    private Student student ;

    public Student getStudent() {
        return student;    }

    public void setStudent(Student student) {
        this.student = student;    }

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

    public void setAuthor(String author) {
        this.author = author;    }

    public void setPrice(int price) {
        this.price = price;    }

    public void setTitle(String title) {
        this.title = title;    }

    public PersonDTO2() {
    }

    public Long getId() {
        return id;    }

    public String getAuthor() {
        return author;    }

    public int getPrice() {
        return price;    }

    public String getTitle() {
        return title;    }

    @Override    public String toString() {
        return "PersonDTO2 [id=" + id + ", author=" + author                + ", price=" + price + ", title=" +
                 title + ",  student " + student  +
                "]";    }
}

沒有留言:

張貼留言